News for hackers. Stuff that matters.
Re:Monads in JavaScript by im3w1l on Tuesday July 21, 2015 @10:14AM (#9922372)
I don't think you can define a monad in terms of just (return,join). (return,bind) works, or (fmap,join).

EDIT: As a counterexample to uniqueness, consider fmap defined such that for all f and x, (fmap(f))(x)=[].

It is consistent with your return and join.

Re:Monads in JavaScript by tel on Tuesday July 21, 2015 @12:27PM (#9923418)
Also with your edit it's worth noting that your given fmap cannot be: it violates both functor laws. As it turns out, for Haskell and most datatype-like functors there is exactly one law abiding implementation of fmap implicit in the structure of the type.
Re:Monads in JavaScript by im3w1l on Tuesday July 21, 2015 @01:10PM (#9923833)
Ah yes, you are right.
Re:Monads in JavaScript by tel on Tuesday July 21, 2015 @12:18PM (#9923351)
Sorry, that's a good point. The triple formalism (T, mu, eta) already assumes T to be a functor, but I didn't state that explicitly! So you need (List, map, return, flatten) all of them.