From efae14c9a3fdaf3219b765f6d56c0b3528e89a0b Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Aug 2026 21:54:43 +0100 Subject: [PATCH 1/4] Add Enum.enumFrom/Enum.enumFromTo --- src/Hell.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Hell.hs b/src/Hell.hs index 9e04c61..82e3030 100644 --- a/src/Hell.hs +++ b/src/Hell.hs @@ -2184,6 +2184,10 @@ polyLits = "Ord.lt" (Ord.<) :: forall a. (Ord a) => a -> a -> Bool "Ord.gt" (Ord.>) :: forall a. (Ord a) => a -> a -> Bool + -- Enum + "Enum.enumFrom" enumFrom :: forall a. Enum a => a -> [a] + "Enum.enumFromTo" enumFromTo :: forall a. Enum a => a -> a -> [a] + -- Tuples "Tuple.(,)" (,) :: forall a b. a -> b -> (a, b) "Tuple.(,)" (,) :: forall a b. a -> b -> (a, b) From 2d5fdf6bd9e82707033f6519791f266ca912bea7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Aug 2026 21:55:06 +0100 Subject: [PATCH 2/4] Add instances of Enum for Int/Integer/Day/DayOfWeek/Bool/Char --- src/Hell.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Hell.hs b/src/Hell.hs index 82e3030..4c8d37d 100644 --- a/src/Hell.hs +++ b/src/Hell.hs @@ -904,6 +904,12 @@ instances = instance0 @Ord @Text, instance0 @Ord @ByteString, instance0 @Ord @ExitCode, + instance0 @Enum @Int, + instance0 @Enum @Integer, + instance0 @Enum @Day, + instance0 @Enum @DayOfWeek, + instance0 @Enum @Bool, + instance0 @Enum @Char, instance0 @Monad @IO, instance0 @Monad @Maybe, instance0 @Monad @[], From 7c64eead8b6d08f6bce9c4ed2b75cb937005ad31 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Aug 2026 21:55:36 +0100 Subject: [PATCH 3/4] Add syntactic sugar for [x..] and [x..y] --- src/Hell.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Hell.hs b/src/Hell.hs index 4c8d37d..9bfdcf5 100644 --- a/src/Hell.hs +++ b/src/Hell.hs @@ -1232,6 +1232,15 @@ desugarExp userDefinedTypeAliases globals = go mempty squash _ = Left BadDoNotation squash stmts >>= go scope HSE.RecConstr _ qname fields -> go scope $ makeConstructRecord qname fields + -- generators sugars + HSE.EnumFromTo l from to -> do + let enumFromTo' = HSE.Var l (HSE.Qual l (HSE.ModuleName l "Enum") (HSE.Ident l "enumFromTo")) + go scope $ + HSE.App l (HSE.App l enumFromTo' from) to + HSE.EnumFrom l from -> do + let enumFrom' = HSE.Var l (HSE.Qual l (HSE.ModuleName l "Enum") (HSE.Ident l "enumFrom")) + go scope $ HSE.App l enumFrom' from + -- end of generator sugars e -> Left $ UnsupportedSyntax $ show e -- | Handles both user-defined case and primitive type case (Maybe, Either, etc.) From 151f3b7ebab80402821f2378a3dc93cdb848f1c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Aug 2026 21:56:41 +0100 Subject: [PATCH 4/4] Add example --- examples/45-enum.hell | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/45-enum.hell diff --git a/examples/45-enum.hell b/examples/45-enum.hell new file mode 100644 index 0000000..1439d61 --- /dev/null +++ b/examples/45-enum.hell @@ -0,0 +1,12 @@ +main = do + IO.print $ List.take 5 $ Enum.enumFrom 1 + IO.print $ Enum.enumFromTo 1 10 + IO.print $ List.take 5 $ Enum.enumFrom 'a' + IO.print $ List.take 5 $ Enum.enumFrom Bool.False + IO.print $ List.take 5 $ Enum.enumFrom (Int.toInteger 1) + IO.print $ List.take 5 $ Enum.enumFrom $ + Maybe.maybe (Error.error "Bad day.") Function.id $ Day.fromGregorianValid (Int.toInteger 2020) 01 01 + + -- simple list generators + IO.print [1 .. 3] + IO.print $ List.take 5 ['a' ..]