4 ms·
Not sure I get the point; of course monads reduce to a functor with two natural transformations (η/μ) that satisfy the monad coherence conditions. That's ... li
by frumplestlatz 1y ago
Not sure I get the point; of course monads reduce to a functor with two natural transformations (η/μ) that satisfy the monad coherence conditions. That's ... literally what a monad is.
- η[i]: i → t i: this is return/pure.
- μ[i]: t (t i) → t i: this is join.
Now conform to the coherence conditions (aka the monad laws), and you have ... a monad. So why not call it that? It's convenient to have a name for it, and nothing stops you from passing around return/join as freestanding natural transformations if you really want to.
- JHonaker 1y agoThis is beautiful whether you interpret it genuinely or as satire.
- mrkeen 1y agoWell he's suggesting natural transformations as an improvement over monads (different ones won't compose without transformers), but he's scant on examples. Show me the behaviour of a State/Either stack!
- codebje 1y agoThe system being demonstrated only has three effects: World, State, and Stop, and all the valid combinations of those are given at the very end of the document. As far as I can tell, these natural transformations are equivalent to the type class instances required for monad transformers. You need some way to transform a computation in a component monad to a computation in the composed monad. There's three combinations of World, State, and Stop expressed, with natural transformations for each specific effect within each combination, ie, "lift" for each part to the composed whole. Those particular effects don't sensibly compose any other way than the ones given: there's no (reasonable) interpretation of State of Stops, only for Stops of State, and no reasonable interpretation of World that isn't "on the inside", much like in mtl one always puts IO at the bottom of the stack. If we had an Error effect, though, maybe we'd want to interpret errors within stateful computations and retain the state, maybe we'd want to interpret errors outside the stateful computation and abort the whole thing... But sure, in an effects-based system you'd preferentially use effect composition over monads, and sure, monad transformers is an n^2 problem, but sadly natural transformations between functors obeying certain laws is also an n^2 problem. I think. I do admit to getting lost on what the different squiggles mean, quite a lot.