Functor — incompatible types

by 12/06/2011 09:05:00 AM 0 comments
Here's a handy tidbit for handling types in Functors. From: Functor — incompatible types - Google Groups:


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 + ")"
}

hohonuuli

Developer

Cras 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: