@@ -1,5 +1,9 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2−module Transform.Canonicalize.Setup (environment) where
2+module Transform.Canonicalize.Setup
5+ , typeAliasErrorExplanation
4import Control.Arrow (first)
8import Control.Arrow (first)
5import Control.Monad (foldM)
9import Control.Monad (foldM)
@@ -178,11 +182,11 @@ addTypeAlias moduleName env scc =
178 aliases ->
182 aliases ->
179 throwError
183 throwError
181− [ P.text (eightyCharLines 0 msg1)
185+ [ P.text (eightyCharLines 0 mutuallyRecursiveMessage)
182 , indented (map typeAlias aliases)
186 , indented (map typeAlias aliases)
183− , P.text (eightyCharLines 0 msg2)
187+ , P.text (eightyCharLines 0 typeAliasErrorSegue)
184 , indented (map datatype aliases)
188 , indented (map datatype aliases)
185− , P.text (eightyCharLines 0 msg3)
189+ , P.text (eightyCharLines 0 typeAliasErrorExplanation)
@@ -207,18 +211,22 @@ indented decls = P.vcat (map prty decls) <> P.text "\n"
207 prty decl = P.text "\n " <> pretty decl
211 prty decl = P.text "\n " <> pretty decl
210−msg1 :: String
214+mutuallyRecursiveMessage :: String
215+mutuallyRecursiveMessage =
211−msg1 = "The following type aliases are mutually recursive, forming an \
216+ "The following type aliases are mutually recursive, forming an \
212− \infinite type. When you expand them, they just keep getting bigger:"
217+ \infinite type. When you expand them, they just keep getting bigger:"
215−msg2 = "Instead, you can try something like this:"
217−msg3 :: String
220+typeAliasErrorSegue :: String
218−msg3 =
221+typeAliasErrorSegue =
225+typeAliasErrorExplanation :: String
226+typeAliasErrorExplanation =
219− "It looks very similar, but the 'type' keyword creates a brand new type. \
227+ "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 \
228+ \not just an alias for an existing one. This lets us avoid infinitely \
221− \it during type inference."
229+ \expanding it during type inference."
224-- When canonicalizing, all _values should be Local, but all _adts and _patterns
232-- When canonicalizing, all _values should be Local, but all _adts and _patterns