3 ms·
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 fma
by im3w1l 11y ago
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.
- tel 11y agoSorry, 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.
- tel 11y agoAlso 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.
- im3w1l 11y agoAh yes, you are right.