copilot icon indicating copy to clipboard operation
copilot copied to clipboard

An example default implementation of the `Struct` typeclass based on `GHC.Generics`

Open Qqwy opened this issue 1 year ago • 0 comments

I had a few conversations with @fdedden during and after ZuriHack about the possibility of adding instances of the Struct class for user-defined datatypes with less boilerplate, potentially using Generics.

Furthermore, the separate instances of the Typed class are no longer necessary if one uses an overlappable instance. (Which is fine, as a type will never be both implementing Struct and be one of the other non-struct types at the same time.)

I thought this should be possible and not terribly difficult, so as I had a little time this evening I gave it a shot.

This PR is not intended to be merged; it is only example code that should give you an idea of how GHC.Generics could be used to accomplish the desired task.

Qqwy avatar Jun 12 '24 20:06 Qqwy