Modifying field names in generated Haskell types#2285
Modifying field names in generated Haskell types#2285mmhat merged 13 commits intodhall-lang:masterfrom
Conversation
Gabriella439
left a comment
There was a problem hiding this comment.
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.
Instead of adding a SHOULD NEVER HAPPEN: prefix, I would recommend using Dhall.Core.internalError here
There was a problem hiding this comment.
Thank you for the review; I'll do that.
This commit adds two fields to both constructors of
Dhall.TH.HaskellType:FromDhallinstance will be generated.
ToDhallinstance will be generated.Fixes: #2262