📝⚛️ New on Overreacted: Algebraic Effects for the Rest of Us. This is the introduction to algebraic effects that I needed.
Conversation
Very interesting, thanks!
I didn’t get why it’s called “algebraic effects” 🤔
“by 2025. Remind me to check back in five years!”
That wasn’t necessary! It’s in five years?! 😱
1
2
I think it’s meant to be for the same reason as “algebraic data types”. Because you can perform different kinds of effects.
2
1
I think it's meant to refer to the fact that they follow certain 'algebraic rules'. like in numbers follow certain rules like:
x + 0 = x
x + y = y + x
etc. This means you can move around and rearrange them without changing the semantics of the program.
There was a lecture about them at OPLSS 2018: youtube.com/watch?v=atYp38 - it's technical, but well-explained! (I can't promise my answer agrees with this presentation - it was a while since I saw it)
1
1
8
I went skimming through the lecture notes and it seems like they are inspired by 'algebraic theories', which roughly is what I described with the number example above: arxiv.org/abs/1807.05923 - following the video would be a long detour though - only do so if your really curious!
1
2
Show replies
And for clarity, this is the same reasoning behind the "algebraic" in ADTs.
Sum types: type bool = True | False. You have 1 + 1 = 2 values that can be expressed.
Product types: type twobool = Foo of bool * bool. 2 * 2 = 4 values that can be expressed.
And these are composable.
1
2
I should have a non-binary example for further clarity. (Because 2+2=2*2.)
type color = Red | Green | Blue
type pixel = Pixel of color * color * color * color
So color has 3 values, whereas pixel has 3 * 3 * 3 * 3 = 81 values.
(This isn't really how pixels work but oh well.)
1
1
Show replies



