Doctest, quickcheck and typeclass

Hi all, Is there a way, with doctest and quickcheck, to declare test at typeclass level (such as laws) and play them automatically at instance level? For example: -- | Convert from/to a List to/from an arbitrary data structure -- -- >>> prop > fromList . toList == id class Listable d where fromList :: [a] -> d a toList :: d a -> [a] And this test will be played for each instance. Thanks in advance for your help.

2014-07-14 18:39 GMT+02:00 Gautier DI FOLCO
Hi all,
Is there a way, with doctest and quickcheck, to declare test at typeclass level (such as laws) and play them automatically at instance level?
Hmm, let's try googling for "Testing type class laws". ... Oh, surprise, there is a paper with exactly that title. :-) http://dx.doi.org/10.1145/2430532.2364514 http://wiki.portal.chalmers.se/cse/pmwiki.php/FP/ClassLaws Maybe that does help? (Might need some extra work to actually integrate with doctest, but the groundwork is there, I think.) Best, Janis.

2014-07-14 19:45 GMT+02:00 Janis Voigtländer
2014-07-14 18:39 GMT+02:00 Gautier DI FOLCO
: Hi all,
Is there a way, with doctest and quickcheck, to declare test at typeclass level (such as laws) and play them automatically at instance level?
Hmm, let's try googling for "Testing type class laws".
...
Oh, surprise, there is a paper with exactly that title. :-)
http://dx.doi.org/10.1145/2430532.2364514
http://wiki.portal.chalmers.se/cse/pmwiki.php/FP/ClassLaws
Maybe that does help? (Might need some extra work to actually integrate with doctest, but the groundwork is there, I think.)
Best, Janis.
Thanks, I'll have a look, thanks. Regards.
participants (2)
-
Gautier DI FOLCO
-
Janis Voigtländer