Skip to content

Instantly share code, notes, and snippets.

@globulon
Created February 15, 2012 21:48
Show Gist options
  • Select an option

  • Save globulon/1839211 to your computer and use it in GitHub Desktop.

Select an option

Save globulon/1839211 to your computer and use it in GitHub Desktop.
State Monad Kestrel Combinator
implicit def stateToComprehension[T, S](state: State[T,S]) = new {
implicit val functor = stateFunctor[S]()
val monad = stateMonad[S]()
def map[U](f: T => U) = functor.map(state)(f)
def flatMap[U](f: T => State[U, S]) = monad.flatMap(state)(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment