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

Product Completeness Constraint #51

Open
oliverbunting opened this issue May 27, 2018 · 1 comment
Open

Product Completeness Constraint #51

oliverbunting opened this issue May 27, 2018 · 1 comment

Comments

@oliverbunting
Copy link

oliverbunting commented May 27, 2018

I often find myself using subtype in the following simplified way

fn :: ( Subtype a x
      , Subtype b x
      )
   => x -> (a,b)

Which works fine, but is a little unsafe if i want to ensure that all info in x is captured in either a or b.

I was wondering if there is an existing way, or if it would be possible to extend the constraints offered for product types with the existing machinery to constrain the product of two (or more) supertypes to be equivalent to a single subtype?

Something like:

fn :: ( Subtype a x
      , Subtype b x
      , Product (a,b) x
      )
   => x -> (a,b)
@kcsongor
Copy link
Owner

So what you need is to say that x can be partitioned into a and b? I've thought about this before, but I can't think of a nice story around type inference - this is not necessarily an issue though.

Do you have example use case for this? I'd be interested to see it!

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