News for hackers. Stuff that matters.
Re:Category theory for beginners by kasey_junk on Tuesday February 24, 2015 @10:36AM (#9101128)
A trait is a (possibly abstract) type definition. So trait Functor is defining a type definition for something called Functor.

Functor[F[_]] to the right of the name indicate that the type Functor is paramterized across a "higher kinded type" (ie it is generic and the thing it is generic against is in turn generic). For this definition we will refer to that higher kinded type as F[_].

def defines a method on the type. So def map means that the type Functor has a method map on it. map[A, B] means that the function map is generic across 2 different types and we will label them A & B. Map takes 2 parameters the first is the higher kinded type F parameterized to A (F of A) and the second is a function that transforms any A to a B. Map returns F parameterized to B.

Slide 92 defines it slightly differently. Map is a function with no parameters that returns a function with the first (and only parameter) is a function from A to B and it returns a function from F[A] to F[B].

There are no comments on this comment yet.