2012-04-15

juan_gandhi: (Default)
2012-04-15 03:47 pm

is it insulting to fp people? this renaming, I mean

What I did, I decided not to pass the parameter to trait Functor. It's inside, and it is the 0th dimension component of Functor; the second one is declared too.

It's a little bit awkward with Scala types, I'd be thankful if someone could come up with a better suggestion than asInstanceOf.

Now this looks way more categorical.

trait Functor {
  type f0[_]
  def f1[A,B](f:A=>B): f0[A] => f0[B]
}

object ListFunctor extends Functor {
  type f0[_] = List[_]
  def f1[A,B](f:A=>B)= (as:f0[A]) => as.asInstanceOf[List[A]].map(f)
}