[Haskell-cafe] How to create a list of each constructor value
Joachim Breitner
mail at joachim-breitner.de
Sat Dec 3 19:17:20 UTC 2022
Hi,
Am Samstag, dem 03.12.2022 um 20:12 +0100 schrieb Henning Thielemann:
> > if you want to golf it a bit more, then
> >
> > [minBound..]
> >
> > works as well.
>
> Wouldn't this create an infinite tail of undefined value
That’s what I thought until I learned about this. Anyways, ghci says it
doesn’t:
ghci> [False .. ]
[False,True]
ghci> [LT .. ]
[LT,EQ,GT]
[x..] is just enumFrom x, and the docs for Enum says
> enumFrom and enumFromThen should be defined with an implicit bound,
https://hackage.haskell.org/package/base-4.17.0.0/docs/Prelude.html#t:Enum
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
More information about the Haskell-Cafe
mailing list