The continuation receives both the computed value and the current computer memory. Therefore return invokes it with unchanged computer memory, while sequencing installs a continuation that passes the produced value and updated computer memory to the next computation:
result :: a -> M a
result x k s = k x s

bind :: M a -> (a -> M b) -> M b
bind p f k s = p (\x s' -> f x k s') s
For left identity, expand the two definitions:
For right identity,
For associativity, both groupings reduce to the same expression:
By function extensionality, these establish all three monad laws:

Articles by others on the same topic (0)

There are currently no matching articles.