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

Add InjectionK and BijectionK #271

Open
MansurAshraf opened this issue Sep 7, 2017 · 1 comment
Open

Add InjectionK and BijectionK #271

MansurAshraf opened this issue Sep 7, 2017 · 1 comment

Comments

@MansurAshraf
Copy link
Contributor

Cats have InjectionK but their invert function returns Option[F[_]] which they are unwilling to change. It would nice to have InjectionK with invert defined as Try[F[_]] as we have for all our existing injections. While Option[F[_]] maybe more theoretically correct, I have found Try[F[_]] to be more useful as I usually want to do something with he exception when inversion fails!. We would also need FunctionK as well

@johnynek
Copy link
Collaborator

johnynek commented Sep 7, 2017

I think this is a great idea.

Of course, I will likely not get to it very soon. Something like:

trait BijectionK[F[_], G[_]] {
  def apply[A](f: F[A]): G[A]
  def invert[A](g: G[A]): F[A]

  def toBijection[A]: Bijection[F[A], G[A]]
}

trait InjectionK[F[_], G[_]] {
  def apply[A](f: F[A]): G[A]
  def invert[A](g: G[A]): Try[F[A]]
  
  def toInjection[A]: Injection[F[A], G[A]]
}

and of course laws.

Maybe add FunctionK while we are at it, but maybe not actually needed... not clear.

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