An example default implementation of the Struct
typeclass based on GHC.Generics
#516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 implementingStruct
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.