
On Mon, Jan 02, 2023 at 02:01:56PM +0100, J. Reinders wrote:
I think theoretically a type class is indeed all you need even for representation polymorphism. I believe that is what the Sixten language [1] does.
Currently GHC rejects any levity polymorphic function arguments and local binders. Issue #15532 [2] tracks the possibility of relaxing these restrictions. The type class approach is mentioned in that thread.
I seem to recall another thread where there were more suggestions like a special form of type classes that is always guaranteed to monomorphise away and another suggestion that functions that are always guaranteed to inline can also be allowed to be representation polymorphic. But I can’t find this thread again.
Very helpful info, thanks Jaro!