Re:Monad Confusion and the Blurry Line Between Data and Comp...
by spion on Sunday August 07, 2022 @05:54AM
(#32375224)
> Then you're able to conclude that `a` is a monoid
Yep, which is why I'm saying all the interesting bits come from `a` being the monoid in that example.
In the free monad interpreter example, I have no idea though.
Re:Monad Confusion and the Blurry Line Between Data and Comp...
by kmill on Sunday August 07, 2022 @11:38AM
(#32377281)
If there's a point to any of this, I think it's monads let you package up some algebraic structure in the form of a function `m a -> a` that satisfies certain properties, and then you can pass such a function around without any reference to the fact that `a` implements that algebraic structure. This function is the interface. (Is there real practical significance? I'm not sure, but I'm not trying to argue that :-) )
> all the interesting bits come from `a` being the monoid in that example.
Yeah, there's nothing deep there. I just said what I said to underscore that the converse is true, that if anyone were to hand you such a `list a -> a` function then it's encoding some monoid structure on `a` (one of often very many).
I called it `ev` because it's an evaluator/interpreter. To be able to write such a `m a -> a` function, `a` needs to have the same kind of structure that `m` is somehow representing, and you need to be able to map the operation that `m` "contains" to corresponding operations for `a`.
This is that business about free monads being useful for organizing how you write interpreters I believe.