Created
October 31, 2010 19:21
-
-
Save gustafnk/657020 to your computer and use it in GitHub Desktop.
It seems impossible to get a good syntax in CoffeeScript for the CallStream pattern: * http://dbj.org/dbj/?p=514 * http://weblogs.asp.net/bleroy/archive/2010/07/01/oh-yeah-callstream-is-great-to-express-monads.aspx
This file contains hidden or 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
| stateful = (value, state) -> | |
| bind = (operation) -> | |
| stateful(operation.call(bind, value), bind.state) | |
| bind.value = value | |
| bind.state = state | |
| bind | |
| p = stateful(3, "This is the state")((i) -> ++i)((i) -> this.state += "altered"; i * 10)((i) -> i + 2) | |
| console.log("Value: " + p.value + "; state: " + p.state); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment