Last active
February 21, 2020 01:45
-
-
Save Khalian/c11012655439e4903d21fb0eb5797d29 to your computer and use it in GitHub Desktop.
TypeHierarchy.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A classic definition of functor, applicative and monad. | |
trait Functor[T[_]] { | |
def apply[A](a: A): T[A] | |
def map[A, B](f: A => B)(a: T[A]): T[B] | |
} | |
trait Applicative[T[_]] extends Functor[T[_]] { | |
def pmap[A, B](f: T[A => B])(a : T[A]) : T[B] | |
} | |
trait Monad[T[_]] extends Functor[T[_]] { | |
def flatMap[A, B](f: A => T[B])(a: T[A]) : T[B] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment