Is this a valid monad transformer in Javascript?

大兔子大兔子 提交于 2019-11-30 15:44:13

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!