Skip to content

Instantly share code, notes, and snippets.

@AlexMost
Last active December 13, 2015 20:39
Show Gist options
  • Save AlexMost/4971640 to your computer and use it in GitHub Desktop.
Save AlexMost/4971640 to your computer and use it in GitHub Desktop.
подозрение на монаду
fn = (cb) ->
some_async_func1 arg1, (err, results) ->
(return cb err) if err
some_async_func2 results, (err, results2) ->
(return cb err) if err
some_async_func3 results2, (err, results3) ->
cb err, results3
{cont_t, domonad, error_m, lift_sync, lift_async} = require 'libmonad'
fn = (cb) ->
sequence = [
lift_async(2, some_async_func1)
lift_async(2, some_async_func2)
lift_async(2, some_async_func3)
]
worker_monad = cont_t error_m()
(domonad worker_monad, sequence, arg1) ([err, result3]) ->
cb err, result3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment