Skip to content

Instantly share code, notes, and snippets.

@etrepum
Created June 9, 2013 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save etrepum/5745207 to your computer and use it in GitHub Desktop.
Save etrepum/5745207 to your computer and use it in GitHub Desktop.
'error monad' in erlang, re: https://gist.github.com/ericmoritz/5734333
-module(error_m).
-export([return/1, fail/1, bind/2]).
return(V) -> {ok, V}.
fail(V) -> {error, V}.
bind({ok, V}, F) -> F(V);
bind(Err={error, _}, _F) -> Err.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment