Created
June 17, 2014 04:54
-
-
Save dsugden/11aa95e35a4ff6bd183f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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