Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created January 30, 2014 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/8705711 to your computer and use it in GitHub Desktop.
Save xuwei-k/8705711 to your computer and use it in GitHub Desktop.
libraryDependencies += "org.scalaz" %% "scalaz-effect" % "7.1.0-M4"
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