Commit a61fa93e authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'nullary-constructors-json' of...

Merge branch 'nullary-constructors-json' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-node-async
parents fe9ee546 a7dab291
...@@ -56,6 +56,11 @@ instance genericSumDecodeJsonRepConstructor :: ...@@ -56,6 +56,11 @@ instance genericSumDecodeJsonRepConstructor ::
argument <- genericSumDecodeJsonRep inner argument <- genericSumDecodeJsonRep inner
pure $ GR.Constructor argument pure $ GR.Constructor argument
instance genericSumDecodeJsonRepNoArguments ::
GenericSumDecodeJsonRep (GR.NoArguments) where
genericSumDecodeJsonRep _ = do
pure GR.NoArguments
instance genericSumDecodeJsonRepArgument :: instance genericSumDecodeJsonRepArgument ::
( Argonaut.DecodeJson a ( Argonaut.DecodeJson a
) => GenericSumDecodeJsonRep (GR.Argument a) where ) => GenericSumDecodeJsonRep (GR.Argument a) where
...@@ -79,6 +84,10 @@ instance genericSumEncodeJsonRepConstructor :: ...@@ -79,6 +84,10 @@ instance genericSumEncodeJsonRepConstructor ::
let argument = genericSumEncodeJsonRep inner let argument = genericSumEncodeJsonRep inner
Argonaut.jsonSingletonObject name argument Argonaut.jsonSingletonObject name argument
instance genericSumEncodeJsonRepNoArguments ::
GenericSumEncodeJsonRep GR.NoArguments where
genericSumEncodeJsonRep GR.NoArguments = Argonaut.jsonNull
instance genericSumEncodeJsonRepArgument :: instance genericSumEncodeJsonRepArgument ::
( Argonaut.EncodeJson a ( Argonaut.EncodeJson a
) => GenericSumEncodeJsonRep (GR.Argument a) where ) => GenericSumEncodeJsonRep (GR.Argument a) where
......
...@@ -17,6 +17,7 @@ data Fruit ...@@ -17,6 +17,7 @@ data Fruit
= Boat { hi :: Int } = Boat { hi :: Int }
| Gravy String | Gravy String
| Pork Int | Pork Int
| Chicken
derive instance eqFruit :: Eq Fruit derive instance eqFruit :: Eq Fruit
derive instance genericFruit :: Generic Fruit _ derive instance genericFruit :: Generic Fruit _
...@@ -76,3 +77,9 @@ spec = ...@@ -76,3 +77,9 @@ spec =
let result2' = Argonaut.decodeJson result2 let result2' = Argonaut.decodeJson result2
Argonaut.stringify result2 `shouldEqual` """{"Gravy":"hi"}""" Argonaut.stringify result2 `shouldEqual` """{"Gravy":"hi"}"""
result2' `shouldEqual` Right input2 result2' `shouldEqual` Right input2
let input3 = Chicken
let result3 = Argonaut.encodeJson input3
let result3' = Argonaut.decodeJson result3
Argonaut.stringify result3 `shouldEqual` """{"Chicken":null}"""
result3' `shouldEqual` Right input3
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment