typeable / generic-arbitrary

Generic method implementations for Arbitrary
MIT License
8 stars 7 forks source link

Adds GenericArbitrary #6

Closed tmortiboy closed 3 years ago

tmortiboy commented 4 years ago

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.

https://github.com/nick8325/quickcheck/pull/290

dredozubov commented 4 years ago

I think it's a great idea, it would be a welcome patch!

dredozubov commented 4 years ago

I've updated the CI script. Can you rebase this PR on master?

ilyakooo0 commented 3 years ago

Closed in favour of #8