forked from Copilot-Language/copilot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copilot-core: Define generic implementations of Struct and Typed meth…
…ods. Refs Copilot-Language#564. This adds functionality for implementing the class methods of `Struct` and `Typed` using `GHC.Generics`. As such, one can now easily define instances of these classes by deriving a `Generic` instance for the struct data type, i.e., ```hs data MyStructType = ... deriving Generic instance Struct MyStructType where typeName = typeNameDefault toValues = toValuesDefault updateField = updateFieldDefault instance Typed MyStructType where typeOf = typeOfDefault ``` This work is based off of an initial implementation by Marten Wijnja (@Qqwy). Note that I do not yet change any of the default implementations of any `Struct` or `Typed` methods. This is because several `Struct` instances in the wild currently do not define implementations of `updateField`, and moreover, they also do not define `Generic` instances for the corresponding data types. As such, changing the default implementation of `updateField` to use a `Generic`-based default would cause these instances in the wild to no longer compile. We will explore changing the default implementations after a suitable transition period. Co-authored-by: Marten Wijnja <[email protected]>
- Loading branch information
1 parent
633c7b9
commit 7bec492
Showing
1 changed file
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters