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

Disassociate & associate #32

Open
erisco opened this Issue Jun 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@erisco
Copy link

erisco commented Jun 10, 2018

Not sure about the names but I am interested in two definitions like this:

disassociate :: forall u v s
  .   Contractable s u
  =>  R.Union u v s
  =>  Variant s
  ->  Either (Variant u) (Variant v)
disassociate s =
  case contract s of
    Just u -> Left u
    Nothing -> Right (unsafeCoerce s)

associate :: forall u v s
  .   R.Union u v s
  =>  R.Union v u s
  =>  Either (Variant u) (Variant v)
  ->  Variant s
associate (Left u) = expand u
associate (Right v) = expand v

Idealistically, the conversions would be with a variant of variants, but the inference for a big-union constraint I am anticipating to be a nightmare. This is more simplistic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment