rudymatela / leancheck

enumerative property-based testing for Haskell
https://hackage.haskell.org/package/leancheck
Other
52 stars 8 forks source link

please add instance Listable Numeric.Natural #22

Open jwaldmann opened 1 year ago

jwaldmann commented 1 year ago

it seems that Numeric.Natural https://hackage.haskell.org/package/base-4.18.0.0/docs/Numeric-Natural.html is the standard non-negative integer type now.

I would welcome a Listable instance. Simply this?

instance T.Listable Natural where
  tiers = T.mapT (fromIntegral @T.Natural) T.tiers

Later, Test.LeanCheck.Util.Types.Natural could be dropped.

rudymatela commented 1 year ago

The Listable Numeric.Natural instance is available in the leancheck-instances (leancheck-instances on GitHub).

For now, with both leancheck and leancheck-instances installed you can get the instance for Natural (and more) with:

import Test.LeanCheck
import Test.LeanCheck.Instances

My intention not including these instances in the LeanCheck package was to keep the dependency footprint low.

... though I now see that Numeric.Natural has been available in base since GHC 7.10... So perhaps it is worth migrating it to the main LeanCheck package. :thinking: Though I will need some CPP tricks to keep near-backwards compatibility with Haskell98, GHC 7.8 and Hugs. It will take a little while to flesh-out the migration as I need to coordinate a new release of leancheck-instances as well.

(I'll keep this issue open while I investigate and until I complete the migration.)

Thanks for the suggestion!