Side note: I am relatively new here and am using the Mlem app. It seems like posting a link is done in the same way as a Reddit-style text post rather than a bare link. Did I do this right?
Side note: I am relatively new here and am using the Mlem app. It seems like posting a link is done in the same way as a Reddit-style text post rather than a bare link. Did I do this right?
Yes, this pattern is covered in my post on algebraic data types (linked at the start of the object algebras post.) The problem you mention about adding new data variants is exactly what object algebras solves. With object algebras data and functions are only co-located at the smallest possible granularity, so the desired functions and the desired data types can be composed as needed.
I get the concern. I haven’t seen the pattern used in practice in an OO context, so I also can’t say for certain where this breaks down. Something to note, though, is that object algebras in an OOP context are equivalent to the final tagless pattern in an FP context, and it’s not uncommon for entire functional applications to be based around final tagless. This gives me some level of confidence that it would only take a reasonable amount of discipline to build a system based on object algebras.
Thank you!