Skip to content

Instantly share code, notes, and snippets.

@imeredith
Created June 27, 2012 10:06
Show Gist options
  • Save imeredith/3003100 to your computer and use it in GitHub Desktop.
Save imeredith/3003100 to your computer and use it in GitHub Desktop.
new Monad[IntS] {
def map[A, B](f: A => B) = (a: IntS[A]) => IntS((i: Int) => {
val res = a.k(i)
(res._1, f(res._2))
})
def flatMap[A, B](f: A => IntS[B]) = (a: IntS[A]) => IntS((i: Int) => {
val res = a.k(i)
f(res._2).k(i)
})
def point[A](a: A) = IntS((i: Int) => (0, a))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment