Created
December 14, 2014 22:00
-
-
Save ryoppy/2756593ca3e068c6edf6 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> def fid[F[_], A](a: F[A]): F[A] = a | |
warning: there was one feature warning; re-run with -feature for details | |
fid: [F[_], A](a: F[A])F[A] | |
scala> fid(List(1)) | |
res0: List[Int] = List(1) | |
scala> fid(Option(1)) | |
res1: Option[Int] = Some(1) | |
scala> fid(Right(1)) | |
<console>:9: error: no type parameters for method fid: (a: F[A])F[A] exist so that it can be applied to arguments (scala.util.Right[Nothing,Int]) | |
--- because --- | |
argument expression's type is not compatible with formal parameter type; | |
found : scala.util.Right[Nothing,Int] | |
required: ?F[?A] | |
fid(Right(1)) | |
^ | |
<console>:9: error: type mismatch; | |
found : scala.util.Right[Nothing,Int] | |
required: F[A] | |
fid(Right(1)) | |
^ | |
scala> type FRight[A] = Either[String, A] | |
defined type alias FRight | |
scala> fid[FRight, Int](Right(1)) | |
res4: FRight[Int] = Right(1) | |
scala> fid[({type F[A] = Either[String, A]})#F, Int](Right(1)) | |
res5: scala.util.Either[String,Int] = Right(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment