Max S. New ⚜️ on Nostr: I've found a lot of people in PL don't know the relationship or difference between ...
I've found a lot of people in PL don't know the relationship or difference between algebraic effects and effect handlers. This is somewhat understandable to an outsider because they came out of the same line of work.
Algebraic effects are based on the observation that we can describe many monads we use for effects as being the monad of free algebras for an algebraic theory. One of the most basic observations is that the state monad is the free algebras for an algebraic theory of read and write operations. This theorem is only true because of the equations imposed on the interaction between reading and writing.
Effect handlers are based on the observation that exception handling can be generalized from exceptions to any monad generated by a signature but *no equations*. This is basically because the free algebras of a theory are just trees so you can pattern match on the structure of that tree. So you can talk about read and write operations but you don't get the state monad you get "read+write trees" that you can pattern match on and write handlers that violate the equational theory of state e.g. computing not just the final state but the trace of all intermediate states of the computation.
Published at
2026-05-21 13:36:03 UTCEvent JSON
{
"id": "05d7382db58c97bf0413a652965d451d097ec55690bcb275f883e41bd56a0cc4",
"pubkey": "6ee7a8bc68fd2815f988ce75f2c5ee48240d48642fa37024af4c3564184b134e",
"created_at": 1779370563,
"kind": 1,
"tags": [
[
"proxy",
"https://types.pl/users/maxsnew/statuses/116612829229828745",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "I've found a lot of people in PL don't know the relationship or difference between algebraic effects and effect handlers. This is somewhat understandable to an outsider because they came out of the same line of work.\n\nAlgebraic effects are based on the observation that we can describe many monads we use for effects as being the monad of free algebras for an algebraic theory. One of the most basic observations is that the state monad is the free algebras for an algebraic theory of read and write operations. This theorem is only true because of the equations imposed on the interaction between reading and writing.\n\nEffect handlers are based on the observation that exception handling can be generalized from exceptions to any monad generated by a signature but *no equations*. This is basically because the free algebras of a theory are just trees so you can pattern match on the structure of that tree. So you can talk about read and write operations but you don't get the state monad you get \"read+write trees\" that you can pattern match on and write handlers that violate the equational theory of state e.g. computing not just the final state but the trace of all intermediate states of the computation.",
"sig": "4c07c8ac3d66e201f0cd271fef06c6c5d2ba86d97577d1a20b45bf2d040e62cb27b7a27b3d8847a850acd4435b2e9f9be317a098f6f55fced8f08b2d24c81eab"
}