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

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 19th, 2025 09:43 pm
Powered by Dreamwidth Studios