[Haskell-cafe] How to create a list of each constructor value
Joachim Breitner
mail at joachim-breitner.de
Sat Dec 3 19:05:05 UTC 2022
Hi,
Am Mittwoch, dem 30.11.2022 um 16:21 +0100 schrieb Henning Thielemann:
> > I want to create a list of each values in order to create meaningfull
> > error message for the user and simplify my Arbitrary instances.
>
> deriving (Enum, Bounded)
>
> then use [minBound .. maxBound]
if you want to golf it a bit more, then
[minBound..]
works as well.
(I vaguely remember that there was a variant that didn’t even need
Bounded, just, but I don’t recall it right now. Maybe it was
[toEnum 0..]? but that only works for certain instances.)
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
More information about the Haskell-Cafe
mailing list