Skip to content

Instantly share code, notes, and snippets.

@vhutov
Created June 23, 2020 22:09
Show Gist options
  • Save vhutov/c97c81aaba48f6a53bf756eec24fd053 to your computer and use it in GitHub Desktop.
Save vhutov/c97c81aaba48f6a53bf756eec24fd053 to your computer and use it in GitHub Desktop.
Inject
import cats.Inject
type B = Either[Int, Either[String, Double]]
val i = Inject[Int, B].inj(1) // Left(1)
val s = Inject[String, B].inj("hi") // Right(Left(hi))
val d = Inject[Double, B].inj(1.0) // Right(Right(1.0))
Inject[String, B].prj(i) // None
Inject[String, B].prj(s) // Some(hi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment