3 ms·
Those two operations make sense to me. Type signatures and all. Is that all that is needed for something to be a monad?
by lacampbell 10y ago
Those two operations make sense to me. Type signatures and all.
Is that all that is needed for something to be a monad?
- moomin 10y agoThe operations also need to obey the "Monad Laws" https://wiki.haskell.org/Monad_laws https://wiki.haskell.org/Monad_laws. But the intuitive version is that anything with those two operations that doesn't smell funny is a Monad. (Think of it like implementing an interface: anything that matches the type signature will work, but if you write something silly, it won't work right)
- dllthomas 10y agoThe two things you need are actually bind (>>=) and return. As mentioned, though, you should also be sure it obeys the relevant laws.