Advertisement
Guest User

Untitled

a guest
Sep 28th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.34 KB | None | 0 0
  1. trait Functor[F[_]] {
  2.   def fmap[A, B](a: F[A], f: A => B) : F[B]
  3. }
  4.  
  5. object FunctorImplicits {
  6.  
  7.   def fmap[F[_], A, B](a: F[A], f: A => B)(implicit functor: Functor[F]): F[B] =
  8.     functor.fmap(functor, f)
  9.  
  10.  
  11.   implicit object OptionFunctor extends Functor[Option] {
  12.     def fmap[A, B](a:Option[A], f: A => B): Option[B]
  13.       = a map f
  14.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement