haskell-to-elm/haskell-to-elm

Support all Aeson options

ollef opened this issue · 3 comments

ollef commented

The options that we take into account in the code are the following:

  • fieldLabelModifier
  • constructorTagModifier
  • allNullaryToStringTag
  • omitNothingFields
  • sumEncoding
    • TaggedObject
    • UntaggedValue
    • ObjectWithSingleField
    • TwoElemArray
  • unwrapUnaryRecords
  • tagSingleConstructors

But most of them, save for what's set in defaultOptions, are untested. So a big part of this issue is to add tests to haskell-to-elm-test for the different options, or find another way to test them, and fix any issues that come up.

Write tests for the following options:

  • fieldLabelModifier
  • constructorTagModifier
  • allNullaryToStringTag
  • omitNothingFields
  • sumEncoding
    • TaggedObject
    • UntaggedValue
    • ObjectWithSingleField
    • TwoElemArray
  • unwrapUnaryRecords
  • tagSingleConstructors

There is a very restricted Options type in the library. I think it should either be a superset of aeson's, or directly use aeson's.

ollef commented

The Options type in this library is to configure what the Elm type should be like, so it doesn't really make sense that it should have all the options that Aeson has (but perhaps some others?). The JSON derivation functions take both a haskell-to-elm Options and an Aeson Options and they're both used.

ollef commented

I've fixed a problem with omitNothingFields and added support for testing with different options to haskell-to-elm-test. It's still a bit manual though, and we should find a way to automate it.