-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repr: use attributes for local function overrides
Currently, the functions `Repr.{like,map}` behave somewhat oddly when passed custom behaviour for one or more of the generic options: it evaluates all derivers on the typerep and packs the resulting functions into a `Custom` typerep containing those implementations. This hides the structure of the type, but otherwise behaves sensibly as long as the derivers behave "linearly", e.g.: ```ocaml derive (pair t1 t2) = derive (pair (partial ~derive:(derive t1) ()) (partial ~derive:(derive t2) ())) ``` but this is not always the case. An example is `pre_hash` which attempts to unbox the pre-hash representation of "simple" types and so behaves differently when complex types have simple components "pre-evaluated" as is currently the case. This commit changes the implementation of `Repr.{like,map}` to instead add custom implementations as _type attributes_ on the original type. These attributes don't hide the internal structure of the type in a `Custom` typerep, making function overrides transparent to derivers that don't care about those overrides.
- Loading branch information
Showing
12 changed files
with
232 additions
and
143 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
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
Oops, something went wrong.