You can use `generic-arbitrary` like this
```haskell import Test.QuickCheck.Arbitrary.Generic data CristalK6C ... deriving Generic deriving (Arbitrary) via GenericArbitrary CristalK6C ```
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
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.