Skip to content

Instantly share code, notes, and snippets.

@mmollaverdi
Created October 27, 2016 17:53
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 mmollaverdi/7aa392fcbf975ddb7b3355f79774fb61 to your computer and use it in GitHub Desktop.
Save mmollaverdi/7aa392fcbf975ddb7b3355f79774fb61 to your computer and use it in GitHub Desktop.
implicit val OptionApplicative = new Applicative[Option] {
def ap[A, B](ff: Option[A => B])(fa: Option[A]): Option[B] = for {
f <- ff
a <- fa
} yield f(a)
def pure[A](a: A): Option[A] = Option(a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment