-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Unsure if this belongs to argonaut-aeson-generic, or Argonaut.
Here's a few test datatypes in PureScript:
data TestSum
= Nullary
| Bool Boolean
| Int Int
| Number Number
data TestData
= TMaybe (Maybe TestSum)
| TEither String
newtype Foo = Foo
{ _fooE :: Either String Int
, _fooTestSum :: TestSum
, _fooTestData :: TestData
}
and test value:
testFoo = Foo
{ _fooE: Left "foo"
, _fooTestSum: Nullary
, _fooTestData: TEither "foo"
}
Options are:
ops :: Options
ops = Options
{ sumEncoding: TaggedObject { tagFieldName: "tag", contentsFieldName: "contents" }
, tagSingleConstructors: true
, allNullaryToStringTag: true
}
Encoding to JSON:
z = genericEncodeAeson ops testFoo
log $ stringify $ z
the result is:
{
"_fooTestSum": {
"tag": "Nullary"
},
"_fooTestData": {
"tag": "TEither",
"contents": "foo"
},
"_fooE": {
"tag": "Left",
"value": "foo"
}
}
The made-up type TEither correctly uses "contents". The standard library Either uses "value".
I think this breaks compatibility with Aeson on the Haskell side, which uses "contents" for all datatypes.
It looks like Argonaut is picking up the encoding options from somewhere else, for the Either.
I am trying to update Purescript Bridge using argonaut-aeson-generic: eskimor/purescript-bridge#89
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels