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

October 2025

S M T W T F S
    1 23 4
5 678 9 1011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 10th, 2025 11:58 pm
Powered by Dreamwidth Studios