Skip to content

Instantly share code, notes, and snippets.

@vmarquez
Created November 3, 2014 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmarquez/74353ca4c1ce264f02c0 to your computer and use it in GitHub Desktop.
Save vmarquez/74353ca4c1ce264f02c0 to your computer and use it in GitHub Desktop.
Option to State
def OtoS[A](o: Option[A => A]): State[A,A] =
o match {
case Some(f) => State[A,A](a => {
val na = f(a)
(na,na)
})
case None => State[A,A](a => (a,a))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment