Last active
December 14, 2015 06:48
-
-
Save hisui/5044903 to your computer and use it in GitHub Desktop.
Play2's Applicative to Scalaz's one
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
import scalaz._ | |
import scalaz.Scalaz._ | |
object Play4Scalaz { | |
type PlayApp[M[_]] = play.api.libs.functional.Applicative[M] | |
implicit def applicative[M[_]:PlayApp]:Applicative[M] = | |
new Applicative[M] { | |
override def apply[A,B](f:M[A => B], a:M[A]) = implicitly[PlayApp[M]].apply(f, a) | |
override def fmap[A,B](r:M[A], f: A => B) = implicitly[PlayApp[M]].map(r, f) | |
override def pure[A](a: => A) = implicitly[PlayApp[M]].pure[A](a) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment