3 ms·
Here is Haskell's Monad: class Monad m where (>>=) :: m a -> ( a -> m b) -> m b (>>) :: m a -> m b -> m b return :: a
by bowsamic 3y ago
Here is Haskell's Monad:
class Monad m where
(>>=) :: m a -> ( a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
and these functions must obey the properties
return a >>= k = k a
m >>= return = m
m >>= (\x -> k x >>= h) = (m >>= k) >>= h
Anything other than the definition I gave is an analogy that will only work for certain examples, that is, unless you can mathematically prove that your analogy is isomorphic to this definition
- supermatt 3y agoYeah, my definition works for all those examples.
- bowsamic 3y agoOkay, then prove that your definition of a monad is isomorphic to the given definition
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- uxp8u61q 3y agoHow does your "definition" (I will take that to mean "an abstract wrapper for some properties that you can apply sequential transforms on" from your first comment) apply to e.g. the monad whose algebras are monoids?