DEV Community

Discussion on: Functional Programming in JS: Functor - Monad's little brother

Collapse
 
vampiire profile image
Vamp • Edited

great explanation thank you. so if i am following, for a promise to be monadic it would have to change the behavior of its .then method:

  • (lazy): does not evaluate until .then is appended
  • cb returns a promise: Promise<Promise<TInnerResolve>>

but a cb returning a value i can’t picture because .then has to source from a promise. meaning the value (Mb?) would never be available at the outer scope, only in the closure.

as an aside how would a promise (an asynchronous task representation) look in fp?