Apr. 15th, 2012

juan_gandhi: (Default)
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)
}

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

September 2025

S M T W T F S
 1 2345 6
78 9 10 111213
14 151617 181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 19th, 2025 06:26 pm
Powered by Dreamwidth Studios