@@ -1,5 +1,9 @@
11{-# OPTIONS_GHC -Wall #-}
2−module Transform.Canonicalize.Setup (environment) where
2+module Transform.Canonicalize.Setup
3+ ( environment
4+ , typeAliasErrorSegue
5+ , typeAliasErrorExplanation
6+ ) where
37
48import Control.Arrow (first)
59import Control.Monad (foldM)
@@ -178,11 +182,11 @@ addTypeAlias moduleName env scc =
178182 aliases ->
179183 throwError
180184 [ P.vcat
181− [ P.text (eightyCharLines 0 msg1)
185+ [ P.text (eightyCharLines 0 mutuallyRecursiveMessage)
182186 , indented (map typeAlias aliases)
183− , P.text (eightyCharLines 0 msg2)
187+ , P.text (eightyCharLines 0 typeAliasErrorSegue)
184188 , indented (map datatype aliases)
185− , P.text (eightyCharLines 0 msg3)
189+ , P.text (eightyCharLines 0 typeAliasErrorExplanation)
186190 ]
187191 ]
188192
@@ -207,18 +211,22 @@ indented decls = P.vcat (map prty decls) <> P.text "\n"
207211 prty decl = P.text "\n " <> pretty decl
208212
209213
210−msg1 :: String
211−msg1 = "The following type aliases are mutually recursive, forming an \
212− \infinite type. When you expand them, they just keep getting bigger:"
214+mutuallyRecursiveMessage :: String
215+mutuallyRecursiveMessage =
216+ "The following type aliases are mutually recursive, forming an \
217+ \infinite type. When you expand them, they just keep getting bigger:"
213218
214−msg2 :: String
215−msg2 = "Instead, you can try something like this:"
216219
217−msg3 :: String
218−msg3 =
219− "It looks very similar, but the 'type' keyword creates a brand new type. \
220− \By giving the type an explicit name, we can avoid infinitely expanding \
221− \it during type inference."
220+typeAliasErrorSegue :: String
221+typeAliasErrorSegue =
222+ "Try this instead:"
223+
224+
225+typeAliasErrorExplanation :: String
226+typeAliasErrorExplanation =
227+ "It looks very similar, but the 'type' keyword creates a brand new type, \
228+ \not just an alias for an existing one. This lets us avoid infinitely \
229+ \expanding it during type inference."
222230
223231
224232-- When canonicalizing, all _values should be Local, but all _adts and _patterns