(no title)
oisdk | 5 months ago
My overall point was that I felt your original comment was a little confused about algebraic effects. You seemed to think that the "algebra" in "algebraic effects" didn't refer to algebraic operations on normal values, which is incorrect. The basic middle-school algebra of a ring (+, *, etc., with all of the normal laws) does indeed give rise to an algebraic effect, and code that uses that effect can just be normal code like `x = 2 * y`. The "effect" here is the "ring" effect.
However, I don't think that this discussion is that productive. If you want to understand algebraic effects, unfortunately there is no substitute for just reading through the fundamental literature (like the paper I linked). I would love to be able to give you a short, easy-to-understand example that explains all the ideas in a few lines, but the concept just isn't that simple.
I see this a lot on this forum in particular: people like to develop a vague intuition for something rather than really understanding the concept properly, but almost always their "intuition" is very inaccurate, and they understand the thing less well than they think they do. Then, they try and teach others the concept, and those learners are even more misled.
----------------------------------------------------------------------
I will try and point out some misconceptions in your last comment here, but again I will caution that I don't think you will be able to fully understand the topic just by reading these comments.
> So, with algebraic effects, I would expect that this is about the ways that effects can be combined using basic algebra tools.
I understand, but that is not what algebraic effects is about.
The "algebra" in algebraic effects doesn't refer to an algebra for combining effects, it refers to algebras like monoid etc., and you get an effect for any particular algebra.
> In effects, I'd expect that you are combining whatever it is an effect is.
This is incorrect. First, there are algebras that have no "combining" at all, and second, the algebras involved are just the normal algebras you're already familiar with, like the boolean algebra etc.
> You seem to be saying that an effect is a standard value? But, that seems at odds with the definitions that distinguish "pure" functions from those that have "effects" being defined by things that they cause to happen.
Yes, an effect is a standard value. And yes, we often want to distinguish pure functions from effectful ones. (By the way, this does not mean that effectful functions are somehow not standard values)
However, in an algebraic effect the algebra does not combine effects.
> It isn't enough to say "writes to stderr", we want to know that it does so without clobbering someone else currently writing to the same spot.
I mean, obviously if the write is going to be performed concurrently you'll need more guarantees.
I included one law that might be important, but you could easily add more. That doesn't change the core concept.
> So, when asking for an example, I'm hunting for something to meet me somewhere in the middle. Sucks that this commonly comes down to "writes to a logger."
I'm not sure what you mean by the "middle"—middle between what two extremes? I picked the writing to a logger example because it was simple, and showed a simple law. The key-value store in the post is a little more complex, and involves a few more laws. In the paper there's even more examples: I/O etc. You have a lot of examples available to you!
taeric|5 months ago
The paper you linked confuses me on this stance, as it explicitly goes through the effort of defining operations as distinct from the values they produce. And it then shows how they can be manipulated using operations. To quote: "Think of a value as an inert datum that needs no further computation, such as a boolean constant, a numeral, or a λ-abstraction. An operation takes a parameter p, for instance the memory location to be read, or the string to be printed, and a continuation κ, which is a suspended computation expecting the result of the operation, for instance the contents of the memory location that has been read" I read that as explicitly setting up how to use algebraic constructs on operations. You are taking the stance that that is not what they are doing?
That all said, I fully sympathize that you are likely hitting a blind spot of mine. I'm already fine reading up more on this paper later, so I'm not wanting to burden you on trying to cover it again.