Skip to content

Instantly share code, notes, and snippets.

@jdegoes
Created March 17, 2014 22:07
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 jdegoes/9609376 to your computer and use it in GitHub Desktop.
Save jdegoes/9609376 to your computer and use it in GitHub Desktop.
StateT combinator
def whatif[S, A](f: StateT[M, S, A]): StateT[M, S, A] = {
for {
oldState <- read(identity[S])
rez <- f.imap(Function.const(oldState))
} yield rez
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment