Skip to content

Instantly share code, notes, and snippets.

@zkessin
Last active December 13, 2015 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkessin/4952326 to your computer and use it in GitHub Desktop.
Save zkessin/4952326 to your computer and use it in GitHub Desktop.
@Monad =
Maybe: (value) ->
wrap = (value) ->
just =
v: value
value: () ->
@v
pass: (f) ->
f(@v)
@
chain: (f, nothing) ->
if(@v == nothing)
@
else
val = f(@v)
if(val == nothing)
return @
else
return wrap val
wrap(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment