Ways to achieve Ad-hoc polymorphism?
Hello there,
I'm currently in the process of implementing the type checker for my statically-typed, imperative language with algebraic effects (when I start implementing them), Kima, and I'm mostly making up the design as I go along. Naturally I came across the need for ad-hoc overloading for my builtin functions. I thought I would also provide this feature on the surface language.
My initial thought was to just allow function (argument) overloading, which I'm thinking of extending to general value overloading. Although this might have some weird interactions with mutability.
Another idea was a trait/typeclass system but I'm not sure how complicated that would be to implement.
So my question is: Are there any other interesting ways of achieving ad-hoc polymorphism? Follow-up: Any resources on the subject? I'm reading interesting-looking chapters from Pierce's Types and Programming Languages, but I haven't found anything which looked particularly relevant. Are there other resources which might be useful?
Thanks a lot. This has to be one of my favorite communities on reddit.