agrafix / agrafix/elm-bridge

Apply the `constructorTagModifier` to the JSON but not the type def?

Abierto
#7 3 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Elm
Estrellas
107
Forks
28
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have an existing type like this in my Haskell app:

``` haskell
data FooType
= FooTypeEnum { fooTypeValues :: [Text] }
...
```

With JSON serialization defined which outputs:

`{"enum": { "values": ["value1", "value2", ...]}}`

Which is achieved by using the `fieldLabelModifier` and `constructorTagModifier` options for Aeson.

I'm using the analogous option values in `elm-bridge` to get the json encoding/decoding to match up, but the issue is that `constructorTagModifier` applies to both the type definition AND the json encoders/decoders, where I want it to apply to only the latter.

So I end up with the correct json encoding/decoding, but on the Elm side the type definition has the same modifications applied:

``` haskell
type FooType =
Enum { values: (List String) }
...
```

Which causes issues, especially with constructors like `FooTypeInt`, which ends up being defined as just `Int`.

Is there a way to apply `constructorTagModifer` only to the json encoding/decoding?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.