Yes, I promise I've read the Contributions Guidelines (please feel free to remove this line -- if you leave this line here, I'm going to assume you didn't actually read it).
I think Appendix B incorrectly describes the flatMap (chain, bind) monad method. From the description, this method is used to leave the monad (as an example, the identity function was used to return a value without a "wrapper"). However, the monad does not actually expose any method for doing this.
The flatMap method is used to combine subsequent monads together in a sequential manner, which is the main strength of monads.
The flatMap function signature could look like this (A is a type of current value, F is the monad itself):
function flatMap<B>(fn: (value: A) => F<B>)
Therefore, the identity function cannot be used inside flatMap. In my opinion, the following is a valid example of using flatMap:
const a = Just.pure(5)
const fn = (value) => Just.pure((value + 3).toString())
const b = a.flatMap(fn) // result: Just("8")
Yes, I promise I've read the Contributions Guidelines (please feel free to remove this line -- if you leave this line here, I'm going to assume you didn't actually read it).
I think Appendix B incorrectly describes the
flatMap(chain,bind) monad method. From the description, this method is used to leave the monad (as an example, theidentityfunction was used to return a value without a "wrapper"). However, the monad does not actually expose any method for doing this.The
flatMapmethod is used to combine subsequent monads together in a sequential manner, which is the main strength of monads.The flatMap function signature could look like this (
Ais a type of current value,Fis the monad itself):Therefore, the
identityfunction cannot be used insideflatMap. In my opinion, the following is a valid example of usingflatMap: