Skip to content

Instantly share code, notes, and snippets.

@nuttycom
Created July 25, 2012 16:25
Show Gist options
  • Save nuttycom/3177071 to your computer and use it in GitHub Desktop.
Save nuttycom/3177071 to your computer and use it in GitHub Desktop.
Identity Monad
trait Monad[M[_]] {
def pure[A](a: A): M[A]
def flatMap[A, B](f: A => M[B]): M[A] => M[B]
def map[A, B](f: A => B): M[A] => M[B] = flatMap(a => pure(f(a)))
}
object Id {
type Id[X] = X
implicit val M: Monad[Id] = sys.error("todo")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment