Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less cpp noise in properties using type synonyms #84

Open
chessai opened this issue Jan 6, 2019 · 4 comments
Open

less cpp noise in properties using type synonyms #84

chessai opened this issue Jan 6, 2019 · 4 comments

Comments

@chessai
Copy link
Collaborator

chessai commented Jan 6, 2019

instead of:

prop1 :: forall proxy f.
#if HAVE_QUANTIFIED_CONSTRAINTS
(blah)
#else 
(blah1)
#endif 
  => proxy f -> Property
...

prop1 :: forall proxy f.
#if HAVE_QUANTIFIED_CONSTRAINTS
(blah)
#else 
(blah1)
#endif 
  => proxy f -> Property

we can have, using Bifunctor as an example, the following:

type BifunctorProp f =
  ( Bifunctor f
#if HAVE_QUANTIFIED_CONSTRAINTS
  , forall x y. (Eq x, Eq y) => Eq (f x y)
  , forall x y. (Show x, Show y) => Show (f x y)
  , forall x y. (Arbitrary x, Arbitrary y) => Arbitrary (f x y) 
#else 
  , Eq2 f
  , Show2 f
  , Arbitrary2 f
#endif 
  ) => proxy f -> Property

prop1 :: forall f. BifunctorProp f
prop2 :: forall f. BifunctorProp f
...
prop3million :: forall f. BifunctorProp f

this would help reduce at least some of the noise, and wouldn't be visible externally, since it only affects the internal properties (ie not the user-facing functions of type Proxy a -> Laws)

@chessai
Copy link
Collaborator Author

chessai commented Aug 8, 2019

this requires constraintkinds. do those work in 7.4? a comment from ekmett in the documentation for the constraints package seems to indicate that they do not.

@andrewthad
Copy link
Owner

I think this is a good idea. Even without ConstraintKinds:

class 
  ( Bifunctor f
#if HAVE_QUANTIFIED_CONSTRAINTS
  , forall x y. (Eq x, Eq y) => Eq (f x y)
  , forall x y. (Show x, Show y) => Show (f x y)
  , forall x y. (Arbitrary x, Arbitrary y) => Arbitrary (f x y) 
#else 
  , Eq2 f
  , Show2 f
  , Arbitrary2 f
#endif
  ) => TestableBifunctor f

instance 
  ( Bifunctor f
#if HAVE_QUANTIFIED_CONSTRAINTS
  , forall x y. (Eq x, Eq y) => Eq (f x y)
  , forall x y. (Show x, Show y) => Show (f x y)
  , forall x y. (Arbitrary x, Arbitrary y) => Arbitrary (f x y) 
#else 
  , Eq2 f
  , Show2 f
  , Arbitrary2 f
#endif
  ) => TestableBifunctor f

prop1 :: forall f. TestableBifunctor f => proxy f -> Property
prop2 :: forall f. TestableBifunctor f => proxy f -> Property

In the values exposed to the end user, we would still want to make sure that we write out the full signature.

@chessai
Copy link
Collaborator Author

chessai commented Aug 8, 2019

seems a waste to introduce a new class. pollution. i would rather just wait until we don't have to support 7.4, since 7.6 is when ConstraintKinds don't crash GHC.

@andrewthad
Copy link
Owner

The class wouldn't be visible to users, but regardless I'm fine with waiting until primitive drops support for GHC 7.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants