Skip to content

Instantly share code, notes, and snippets.

@tomwadeson
Created March 22, 2016 17:01
Show Gist options
  • Save tomwadeson/a4f43857d774d4b72691 to your computer and use it in GitHub Desktop.
Save tomwadeson/a4f43857d774d4b72691 to your computer and use it in GitHub Desktop.
scala> case class Callback[A](f: (A => Unit) => Unit) {
| def map[B](g: A => B): Callback[B] = Callback { (h: B => Unit) => f(a => h(g(a))) }
| def flatMap[B](g: A => Callback[B]): Callback[B] = Callback { (h: B => Unit) => f(a => g(a).f(b => h(b))) }
| }
defined class Callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment