<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>You can use `generic-arbitrary` like this <br>
    </p>
    <pre>```haskell
import Test.QuickCheck.Arbitrary.Generic

data CristalK6C ...
  deriving Generic
  deriving (Arbitrary) via GenericArbitrary CristalK6C
```
</pre>
    <div class="moz-cite-prefix">On 30.11.2022 21:18, PICCA
      Frederic-Emmanuel wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:1434982562.46277715.1669821536049.JavaMail.zimbra@synchrotron-soleil.fr">
      <pre class="moz-quote-pre" wrap="">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:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
    </blockquote>
  </body>
</html>