@@ -904,6 +904,12 @@ instances =
904904 instance0 @ Ord @ Text ,
905905 instance0 @ Ord @ ByteString ,
906906 instance0 @ Ord @ ExitCode ,
907+ instance0 @ Enum @ Int ,
908+ instance0 @ Enum @ Integer ,
909+ instance0 @ Enum @ Day ,
910+ instance0 @ Enum @ DayOfWeek ,
911+ instance0 @ Enum @ Bool ,
912+ instance0 @ Enum @ Char ,
907913 instance0 @ Monad @ IO ,
908914 instance0 @ Monad @ Maybe ,
909915 instance0 @ Monad @ [] ,
@@ -1226,6 +1232,15 @@ desugarExp userDefinedTypeAliases globals = go mempty
12261232 squash _ = Left BadDoNotation
12271233 squash stmts >>= go scope
12281234 HSE. RecConstr _ qname fields -> go scope $ makeConstructRecord qname fields
1235+ -- generators sugars
1236+ HSE. EnumFromTo l from to -> do
1237+ let enumFromTo' = HSE. Var l (HSE. Qual l (HSE. ModuleName l " Enum" ) (HSE. Ident l " enumFromTo" ))
1238+ go scope $
1239+ HSE. App l (HSE. App l enumFromTo' from) to
1240+ HSE. EnumFrom l from -> do
1241+ let enumFrom' = HSE. Var l (HSE. Qual l (HSE. ModuleName l " Enum" ) (HSE. Ident l " enumFrom" ))
1242+ go scope $ HSE. App l enumFrom' from
1243+ -- end of generator sugars
12291244 e -> Left $ UnsupportedSyntax $ show e
12301245
12311246-- | Handles both user-defined case and primitive type case (Maybe, Either, etc.)
@@ -2184,6 +2199,10 @@ polyLits =
21842199 " Ord.lt" (Ord. <) :: forall a . (Ord a ) => a -> a -> Bool
21852200 " Ord.gt" (Ord. >) :: forall a . (Ord a ) => a -> a -> Bool
21862201
2202+ -- Enum
2203+ " Enum.enumFrom" enumFrom :: forall a . Enum a => a -> [a ]
2204+ " Enum.enumFromTo" enumFromTo :: forall a . Enum a => a -> a -> [a ]
2205+
21872206 -- Tuples
21882207 " Tuple.(,)" (,) :: forall a b . a -> b -> (a , b )
21892208 " Tuple.(,)" (,) :: forall a b . a -> b -> (a , b )
0 commit comments