-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow specifying custom code generation settings #131
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.
Looks great 👍
probably could use some documentation updates though
Thanks, docs updated. |
Is anything blocking merge of this? |
We didn't get any feedback from @silky who actually requested that change. |
e24f404
to
0fdca95
Compare
0fdca95
to
8b79edc
Compare
Apologies for never getting around to responding to this; in the end I changed jobs since I needed it :) But at a glance, it definitely does what I wanted, and I'll probably have cause to use it again at some point in the future; so that's great! Thanks :) 🙏🏻 |
Just (User {userName = "John", userAge = 42}) | ||
|
||
|
||
>>> data VeryLongType = VeryLongType { vltName :: String, vltAge :: Int } deriving (Generic, Show) | ||
>>> instance FromJSON VeryLongType where parseJSON = elmStreetParseJson | ||
>>> decode @VeryLongType "{ \"name\": \"John\", \"age\": 42 }" | ||
>>> decode @VeryLongType "{\"age\":42,\"name\":\"John\",\"tag\":\"VeryLongType\"}" |
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.
doesn't seem that long to me 👀 ProjectContractChargingPeriodProjectAccountReferenceVMFactoryBuilderStrategy
I'm playing with ways that would allow resolving #129
while keeping the old behavior (stripping type name prefix) by default.
The important thing is that generated Elm encoders and decoders have to be compatible with ToJSON / FromJSON instances of Haskell types used across Haskell + Elm. This means that both Elm instance and ToJSON / FromJSON must use the same (what I call)
CodeGenSettings
that carry the "field label modifier" function (which for now is the only aspect of code generation that we allow to override).See Type.hs for an example of how this could be used.
I'll need to think if this could be done more nicely over the next few days, but feel free to provide feedback if any.