-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From/ToDhall no longer takes InterpretOptions argument #1696
From/ToDhall no longer takes InterpretOptions argument #1696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree that the aeson
way of doing things makes more sense! Thank you for fixing this 🙂
Awesome! Thanks a lot, Gabriel |
@akrmn: You're welcome! 🙂 |
@akrmn Catching a codebase that used a custom fieldModifier up with this change, and it does not appear that |
@patrickmn: Yeah, it's not currently exported, but it's not hard to locally define: https://hackage.haskell.org/package/dhall-1.31.0/docs/src/Dhall.html#defaultInputNormalizer |
@Gabriel439 for that I'd need the newtype to be exported, right? Or, in other words, how would I externally make an instance with a custom field modifier? (I can't use DerivingVia.) |
@patrickmn: The newtype is exported: https://hackage.haskell.org/package/dhall-1.31.0/docs/Dhall-Core.html#t:ReifiedNormalizer |
@patrickmn: Oh sorry, wrong newtype. Never mind |
... as caught by @patrickmn in #1696 (comment)
@patrickmn: I have a fix up here: #1727 I can also cut a 1.31.1 point release for this |
Awesome, will finish my port as soon as it's merged just in case there's anything else pre-1.31.1. |
* Expose `{default,}InputNormalizer` ... as caught by @patrickmn in #1696 (comment) * Fix missing haddocks Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
All good. Thank you! |
@patrickmn: You're welcome! 🙂 |
Coming from
aeson
, I wanted to defineFromDhall
instances for my types which built onGHC.Generics
but with tweaked options (say, drop prefixes). Ideally, I would write something likeThe problem with this is that
autoWith
itself takes aInterpretOptions
argument, which is set todefaultInterpretOptions
byauto
, the most common entry point. This means that the only way to enforce a canonicalFromDhall
instance for a type is by ignoring the argument toautoWith
, which is confusing for callers. In practice, this PR is only reflecting in the types the fact that all instances ofFromDhall
andToDhall
necessarily ignore theInterpretOptions
, either because they don't need it or because they overwrite it. The only field that was actually used,inputNormalizer
, was kept as an input.InterpretOptions
split into smallerInterpretOptions
record andInputNormalizer
newtype.FromDhall
methodautoWith
andToDhall
methodinjectWith
no longer takeInterpretOptions
arguments, instead, they take anInputNormalizer
, since the only field that instances of these classes ever used wasinputNormalizer
(only used by instances for(->)
).GenericFromDhall
methodgenericAutoWithNormalizer
(renamed fromgenericAutoWith
) andGenericToDhall
methodgenericToDhallWithNormalizer
(renamed fromgenericToDhallWith
) now take anInputNormalizer
in addition to anInterpretOptions
.