Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Created February 7, 2016 14:37
Show Gist options
  • Save derhuerst/8deb93d9fd292b421ce9 to your computer and use it in GitHub Desktop.
Save derhuerst/8deb93d9fd292b421ce9 to your computer and use it in GitHub Desktop.
something like a maybe monad? not sure…
maybe = ->
fns = []
monad = (input) -> fns.reduce ((v, fn) -> fn v), input
Object.assign monad, with: (fn) ->
fns.push (v) -> if v? then fn v else null
monad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment