|
|
|
|
|
by nemo1618
1989 days ago
|
|
> The usual list monad is only one of infinitely many ways to turn the List functor into a monad. So simple, and yet this is a point that I think is rarely made clear enough in "monad explainers." For instance, they almost always talk about "the Maybe monad" -- but this is conflating two things: the Maybe data type, and the Monad instance defined on that type. Propagating "Nothing" is not inherent to the Maybe data type, it's just a convenient behavior to have. Talking about "the List monad" is even more confusing for a newcomer. When they hear "the List monad implements a kind of nondeterminism," it sounds like nondeterminism is a property inherent to lists themselves -- but of course it is nothing of the sort. All Monad instances are, in a sense, arbitrary. |
|
nitpick about this particular example: is there another lawful implementation of Monad for Maybe? i can't think of any, apart from the trivial
(eyeballing the lawfulness, but it'll all be `Nothing` so all the equalities should hold, trivially :D)