Created
February 7, 2013 04:11
-
-
Save groundwater/4728428 to your computer and use it in GitHub Desktop.
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
# Do comprehension chains Monads together | |
var x = do | |
a <- maybe_null( 'Hello World' ) # If returns null/None, none of the following is executed | |
b <- async_call_1( a ) # Returns a Promise | |
c <- async_call_2( b ) # Only executed once the preceding promise is fulfilled | |
d <- async_call_3( c ) | |
return d | |
x.get(function(err,ok){ | |
# function called with err if the above comprehension failed | |
# called with ok=d if the above comprehension succeeded | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment