snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
153 stars 63 forks source link

Monadic Interfaces #229

Open BebeSparkelSparkel opened 1 month ago

BebeSparkelSparkel commented 1 month ago

I'm not sure if this is a good idea or not but I have been thinking about monadic interfaces and the pure interface can just use Identity to use the monadic instance or the RULES pragma for the specific type function. Example

L0neGamer commented 1 month ago

I like the concept a lot, since it lets us have more generality. I'd recommend looking at the difference in code gen at a core level to see whether we're taking a performance hit even though we're using Identity

L0neGamer commented 1 month ago

We also need to think about how this would break backwards compatibility as well as the fact that many structures wouldn't have monadic implementations like this.

Would we remove the pure versions from the classes and implement them in terms of the Monadic, or have both and define them in terms of each other? Would this mean eg updateMap wouldn't be defined with updateWithKey? Or do we keep the hierarchies as they are?

BebeSparkelSparkel commented 1 month ago

I do not think that we can break the interface.

Existing classes can have a monadic class added to them with the *M names.

For future classes depending on what makes the most sense, we can require that either