Skip to content
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

fieldModifier should apply to encoder names as well #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

supermario
Copy link

When I have:

screenshot 2017-11-30 17 29 12

And I'm using the fieldLabelModifier:

screenshot 2017-11-30 17 29 48

The fieldLabelModifier should apply to the encoder field as well, otherwise, my types are mismatched:

screenshot 2017-11-30 17 28 25

@supermario
Copy link
Author

In looking at fixing the failed tests – it seems my "fix" creates a dilemma.

  • I'm using something that results in a prefix on all my Haskell ADTs (i.e. Persistent)
  • I don't want the prefix in my exported Elm record fields

The two conflicting implementation choices for fieldLabelModifier appear to expect of the field names:

Scenario Haskell API / JSON Elm
current implementation unmodified unmodified modified
my "fix" unmodified modified modified

I.e. in my case, I don't want prefixes like postComments in the JSON, I just want comments same as in Elm, hiding the postComments/postPromoted/postAuthor noise in Haskell.

It seems it's not possible to have both these behaviours accommodated with a single fieldLabelModifier implementation 😞

Interested in your thoughts @krisajenkins – perhaps I need to keep my own fork for my scenario. Or did I miss something?

supermario added a commit to supermario/elm-export that referenced this pull request Dec 23, 2017
bchase added a commit to bchase/elm-export that referenced this pull request Jan 25, 2018
`Options`

* change `fieldLabelModifier` to `elmRecordFieldModifier`
* provide `jsonKeyModifier`
* apply these modifiers to generated Elm types, decoders, and encoders

(see also: discussion in krisajenkins#48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant