Created
January 30, 2014 10:12
-
-
Save xuwei-k/8705711 to your computer and use it in GitHub Desktop.
This file contains 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
libraryDependencies += "org.scalaz" %% "scalaz-effect" % "7.1.0-M4" |
This file contains 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
trait MyStuff { def foobar: String } | |
object Main{ | |
import scalaz._,Scalaz._ | |
import effect.IO | |
final class MyFunctorOps[F[_], A](self: F[A], F: Functor[F]){ | |
def foobar(implicit A: A =:= MyStuff): F[String] = | |
F.map(self)(_.foobar) | |
} | |
implicit def myFunctorOps[FA](fa: FA)(implicit F: Unapply[Functor, FA]) = | |
new MyFunctorOps[F.M, F.A](F(fa), F.TC) | |
val a = OptionT[IO, MyStuff](IO(None)) | |
val b = EitherT[IO, Throwable, MyStuff](IO(-\/(new Error))) | |
a.foobar | |
b.foobar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment