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

Union typeclass for abstracting boxed union types #1593

Closed
leandrob13 opened this issue Apr 7, 2017 · 2 comments
Closed

Union typeclass for abstracting boxed union types #1593

leandrob13 opened this issue Apr 7, 2017 · 2 comments

Comments

@leandrob13
Copy link
Contributor

leandrob13 commented Apr 7, 2017

Would it make sense to work on a typeclass that can be defined for boxed union types like, but not limited to, Either or Ior? I have this idea in mind:

trait Union[U[_, _], A, B] extends ApplicativeError[U[A, ?], A] with Monad[U[A, ?]] {
  def isLeft: Boolean

  def isRight: Boolean

  def fold[C](Uab: U[A, B])(fl: A => C, fr: B => C): C

  def leftMap[C](Uab: U[A, B])(fl: A => C): U[C, B]
}

If it does make sense, I could work on the PR.

@peterneyens
Copy link
Collaborator

Also see #974 and #976.

@leandrob13
Copy link
Contributor Author

@peterneyens I see the limitations, specially regarding Validated. Maybe define it only for Either and Ior but I guess it won't be enough to justify its addition to the library. I had a use for it but I guess I might have to rethink my use case.

@LukaJCB LukaJCB closed this as completed Jul 3, 2019
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

3 participants