Monad in Javascript