-
Notifications
You must be signed in to change notification settings - Fork 214
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
Modifying field names in generated Haskell types #2285
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.
The first suggestion I would make is to leave the type of makeHaskellTypes
the same, but create a new makeHaskellTypesWith
function for this purpose, that takes a new Options
argument
The second thing is that I just realized we probably would still need something like fieldModifier
and constructorModifier
here (except in the opposite direction as Dhall.Marshal.Internal
, converting Dhall names to Haskell names). The reason why is that if the Dhall type uses reserved field names (like type
) then the generated Haskell type will still be rejected, even if we don't generate FromDhall
/ ToDhall
instances
This commit adds two fields to both constructors of `Dhall.TH.HaskellType`: One flag to control whether a `FromDhall` instance will be generated and one to control whether a `ToDhall` instance will be generated.
f11709b
to
b8fd86e
Compare
This function controls how a Dhall union field is mapped to a Haskell data constructor.
This function controls how a Dhall record field is mapped to a Haskell record field.
I just wanted to comment that this looks great so far! |
dhall/src/Dhall/TH.hs
Outdated
|
||
toCases :: (Text -> Text) -> [Text] -> Q Exp | ||
toCases f xs = do | ||
err <- [| error $ "SHOULD NEVER HAPPEN: Unmatched " <> show $(pure nameE) |] |
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.
Instead of adding a SHOULD NEVER HAPPEN:
prefix, I would recommend using Dhall.Core.internalError
here
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.
Thank you for the review; I'll do that.
This commit adds two fields to both constructors of
Dhall.TH.HaskellType
:FromDhall
instance will be generated.
ToDhall
instance will be generated.Fixes: #2262