These examples assume a mythical ====
object which means "functionally equivallent". In this case, the same type of monad with the same internal state.
The unit
function for the Monad example should take a value and return a monad for that value.
The f
and g
functions in the monad example take values and return monads, in the promise example they take values and return promies.
The axioms in the promise example hold only if value
is not a promise. I still can't come up with a situation where this matters.
FWIW, the left identity on Promises (the first in your code) is broken in the presence of side-effects - see here