@@ -656,17 +656,23 @@ toReport source err =
656656 Report.toCodeSnippet source region Nothing $
657657 case names of
658658 [] ->
659+ let
660+ makeTheory question details =
661+ H.fillSep $ map (H.dullyellow . H.text) (words question) ++ map H.text (words details)
662+ in
659663 (
660664 H.reflow $
661− "The `" <> N.toString name <> "` value has a direct use of `" <> N.toString name <> "` in its definition."
665+ "The `" <> N.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
662666 ,
663− -- TODO see if shadowing rules out mutation attempts
664667 H.stack
665− [ H.reflow $
666− "To know what `" <> N.toString name
667− <> "` is, I need to know what `" <> N.toString name
668− <> "` is. Let me recursively figure that out. Hmm, I need to know what `"
669− <> N.toString name <> "` is..."
668+ [ makeTheory "Are you are trying to mutate a variable?" $
669+ "Elm does not have mutation, so when I see " ++ N.toString name
670+ ++ " defined in terms of " ++ N.toString name
671+ ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
672+ , makeTheory "Maybe you DO want a recursive value?" $
673+ "To define " ++ N.toString name ++ " we need to know what " ++ N.toString name
674+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ N.toString name
675+ ++ " is, so let’s expand it... This will keep going infinitely!"
670676 , H.link "Hint"
671677 "The root problem is often a typo in some variable name, but I recommend reading"
672678 "bad-recursion"
@@ -724,6 +730,7 @@ toReport source err =
724730 \ the `point.x` syntax to access them."
725731
726732 , H.link "Note" "Read" "tuples"
733+
727734 "for more comprehensive advice on working with large chunks of data in Elm."
728735 ]
729736 )