migamake / json-autotype

Automatic Haskell type inference from JSON input
149 stars 23 forks source link

Duplicate record fields #38

Open agentultra opened 4 years ago

agentultra commented 4 years ago
{
  "synced": true,
  "__synced": true
}

Will generate a record with a duplicated field name

data TopLevel = TopLevel {
    topLevelSynced :: Bool,
    topLevelSynced :: Bool
} deriving (Show,Eq,GHC.Generics.Generic)
mgajda commented 4 years ago

Good point! We have just started an implementation of code generation monad that works around this issue, I am willing to tutor anybody that wants to implement this.

sigrlami commented 4 years ago

@agentultra @mgajda I stumbled into a similar issue working with 3rd party API. What would be the appropriate handler for this? Enumeration might be a good choice to resolve the conflict but it doesn't provide enough context later on.

mgajda commented 4 years ago

@sigrlami Good way to fix this would be to implement the same CodeGen monad as used in xml-typelift. Here is the presentation: https://www.migamake.com/presi/art-of-industrial-code-generation-mar-6-2019-uog-singapore.pdf

I can mentor the change, but at the moment I am rather busy making next-gen type inference for json-autotype.

@agentultra Would your work also fix this issue?

agentultra commented 4 years ago

Sure would

EskoJTH commented 1 year ago

Same issue occurs also with capital letters:

{
  "Synced": true,
  "synced": true
}