[Haskell-cafe] How to create a list of each constructor value
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Wed Nov 30 15:18:56 UTC 2022
Hello, I have a type like this
data InputType = CristalK6C
| MarsFlyscan
| MarsSbs
| SixsFlyMedH
| SixsFlyMedV
| SixsFlyMedVEiger
| SixsFlyMedVS70
| SixsFlyScanUhv
| SixsFlyScanUhv2
| SixsFlyScanUhvTest
| SixsFlyScanUhvUfxc
| SixsSbsFixedDetector
| SixsSbsMedH
| SixsSbsMedV
| SixsSbsMedVFixDetector
deriving (Eq, Show)
I want to create a list of each values in order to create meaningfull error message for the user and simplify my Arbitrary instances.
I do not want to type two time the values.
instance Arbitrary InputType where
arbitrary = oneof (map pure
[ CristalK6C
, MarsFlyscan
, MarsSbs
, SixsFlyMedH
, SixsFlyMedV
, SixsFlyMedVEiger
, SixsFlyMedVS70
, SixsFlyScanUhv
, SixsFlyScanUhv2
, SixsFlyScanUhvTest
, SixsFlyScanUhvUfxc
, SixsSbsFixedDetector
, SixsSbsMedH
, SixsSbsMedV
, SixsSbsMedVFixDetector
]
)
Thanks for your help
Frederic
More information about the Haskell-Cafe
mailing list