I think we can reduce the boiler plate by using DerivingVia language extension:
data Foo = Foo
{ _fooX :: X
, _fooY :: Y
} deriving (Generic)
deriving (Arbitrary) via GenericArbitrary Foo
This also has the added benefit of being able to automatically use types that derive Generic but not Arbitrary in property tests, eg:
prop "Should do something" $ \(GenericArbitrary someoneElsesType) ->
...
This is not quite ready for merge as this change requires GSubterms and RecursivelyShrink to be exported from Test.QuickCheck.Arbitrary, but I have submitted a PR to them and wanted to get your feedback.
I think we can reduce the boiler plate by using
DerivingVia
language extension:This also has the added benefit of being able to automatically use types that derive
Generic
but notArbitrary
in property tests, eg:This is not quite ready for merge as this change requires
GSubterms
andRecursivelyShrink
to be exported fromTest.QuickCheck.Arbitrary
, but I have submitted a PR to them and wanted to get your feedback.https://github.com/nick8325/quickcheck/pull/290