Skip to content

Instantly share code, notes, and snippets.

@AlexMost
Created February 14, 2013 13:44
Show Gist options
  • Save AlexMost/4952895 to your computer and use it in GitHub Desktop.
Save AlexMost/4952895 to your computer and use it in GitHub Desktop.
error_monad
OK = undefined
error_m = ->
is_error = ([err, val]) -> err isnt OK
result: (v) -> [OK, v]
bind: (mv, f) ->
if (is_error mv) then mv else (f mv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment