Last active
August 29, 2015 14:08
-
-
Save erikkaplun/58b7a8737ad39c48dc24 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
import scala.language.higherKinds | |
def optKleisli[M[_]: Applicative, A, B](fn: Kleisli[M, A, B]) = Kleisli[M, Option[A], Option[B]] { | |
case Some(t) => fn(t).map(_.some) | |
case None => Applicative[M].point(none[B]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can write this for any
F[_]
with an instance ofTraverse
: