Last active
March 8, 2021 14:05
-
-
Save deanwampler/77a0158ab8bbc0ba35d631b7d02ed266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> given [L]: Functor[({type λ[α] = Either[L,α]})#λ] with | |
| extension [R1] (either: Either[L,R1]) | |
| def map2[R2](f: R1 => R2): Either[L,R2] = either map f | |
| | |
// defined class given_Functor_R1_λ | |
scala> Right(2).map2(_ * 2.2) | |
val res0: Either[Nothing, Double] = Right(4.4) | |
scala> Left[String,Int]("fail!").map2(_ * 2.2) | |
val res1: Either[String, Double] = Left(fail!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment