Skip to content

Instantly share code, notes, and snippets.

@dsugden
Created June 17, 2014 04:54
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 dsugden/11aa95e35a4ff6bd183f to your computer and use it in GitHub Desktop.
Save dsugden/11aa95e35a4ff6bd183f to your computer and use it in GitHub Desktop.
def sum(i:Int) = StateChange[Better,Int](s => Better.sum(i)(s))
// Lets run the sum computation, and add all the results together
def composeAddResultS(one:Int,two:Int,three:Int): StateChange[Better,Int] =
sum(one).doAgainWithNewState(
firstResult =>
sum(two).doAgainWithNewState( secondResult =>
sum(three).mapResult( thirdResult => firstResult + secondResult + thirdResult) ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment