[squeak-dev] Monads in Squeak
Tony Garnock-Jones
tonyg at leastfixedpoint.com
Thu Aug 4 12:07:04 UTC 2022
Hi Eliot,
On 8/4/22 00:17, Eliot Miranda wrote:
> I'd love to read a definition of the monad laws in plain English.
They're terribly simple: monad composition should have a left and right
identity, and should be associative. That's it.
Unfortunately they're also terribly *general* :-) and I therefore have
the same problem as you when it comes to grokking them in general.
I have to think about specific instances, like the "failure monad"
(Maybe), which is a chain of computations, any of which can "fail",
which causes the remainder of the chain to be skipped; or the "possible
worlds" monad (List, or I suppose more accurately Set), which is a chain
of computations, each of which can yield zero or more possible results.
The chain multiplies out the possibilities, yielding a collection of
possible final answers rather than just one.
Then there's the "boring monad" (Identity) which really just sequences
its operations and may as well just be function composition. The "IO
monad" is just Identity equipped with a few extra IO actions. The
actions fall outside the monad formalism. Similar to IO, the State monad
is just Identity with some get/set operations.
Erm, not sure this helps. Happy to follow up if you have questions.
Cheers,
Tony
More information about the Squeak-dev
mailing list
|