In order to better understand monad transformers I implemented one. Since Javascript is dynamically typed I don\'t mimic type or data constructors but declare only plain old
Is the cause of this problem that the way I apply chain is wrong?
Yes. You need to pass an mf
that returns an arraym
, not an array
like addm
does. You could use
const addmm = x => y => array.map(maybe.of)(addm(x)(y))
arraym.chain(x => arraym.chain( addmm(x) )(arrayOfMaybes))([[10]])
To help with this, you also might consider implementing lift for every monad transformer.