Created
July 25, 2012 16:25
-
-
Save nuttycom/3177071 to your computer and use it in GitHub Desktop.
Identity Monad
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
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