3 ms·
But note that Set is usually not a monad. Writing the functions above is pretty easy but they'll break the rules. In particular, unless our Set identifies its
by dllthomas 5y ago
But note that Set is usually not a monad. Writing the functions above is pretty easy but they'll break the rules.
In particular, unless our Set identifies its items in a way that forces a = b to imply f(a) = f(b), eliminating "duplicates" will sometimes eliminate things which can be distinguished by some function d.
This means that map(d, map(f, set)) might not always equal map(compose(d, f), set), which is required for a functor (which is more general than monad - all monads must be functors, not all functors are monads).