trait Functor[F[_],A] {
def map[B](f: A => B): F[B]
}
case class Box[T](val content: T) extends Functor[Box, T] {
def map[B](f: T => B): Box[B] = Box(f(content))
override def toString = "Box(" + content + ")"
}
Functor — incompatible types
Here's a handy tidbit for handling types in Functors. From: Functor — incompatible types - Google Groups:
hohonuuli
DeveloperCras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 comments:
Post a Comment