3 ms·
You can also look at the Scala implementations if you like. Scala has HKTs so you can write it all directly. trait Functor[F[_]] { def map[A, B](f: A =
by tel 5y ago
You can also look at the Scala implementations if you like. Scala has HKTs so you can write it all directly.
trait Functor[F[_]] {
def map[A, B](f: A => B)(x: F[A]): F[B]
}
trait Applicative[F[_]] extends Functor[F] {
def pure[A](a: A): F[A]
def apply[A, B](f: F[A => B])(x: F[A]): F[B]
def product[A, B](xa: F[A], xb: F[B]): F[(A, B)]
}
trait Monad[F[_]] extends Applicative[F] {
def bind[A, B](f: A => F[B])(x: F[A]): F[B]
def join[A](x: F[F[A]]): F[A]
}