From 5e3b561569ae28dc85106ed97d3e0acbd0cf4e05 Mon Sep 17 00:00:00 2001 From: s0kil Date: Thu, 27 Jul 2023 00:51:01 -0400 Subject: [PATCH] SSC do not encode nullary constructors to strings with the constructor tag --- IHP/ServerSideComponent/Controller/ComponentsController.hs | 5 ++++- IHP/ServerSideComponent/ControllerFunctions.hs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/IHP/ServerSideComponent/Controller/ComponentsController.hs b/IHP/ServerSideComponent/Controller/ComponentsController.hs index d4b5c7506..148a7eb8d 100644 --- a/IHP/ServerSideComponent/Controller/ComponentsController.hs +++ b/IHP/ServerSideComponent/Controller/ComponentsController.hs @@ -29,4 +29,7 @@ instance (Component component controller, FromJSON controller) => WSApp (Compone nextState <- SSC.action currentState theAction SSC.setState nextState - Left error -> putStrLn (cs error) + Left error -> do + putStrLn "Failed Parsing Server Side Component Message As JSON" + putStrLn (cs actionPayload) + putStrLn (cs error) diff --git a/IHP/ServerSideComponent/ControllerFunctions.hs b/IHP/ServerSideComponent/ControllerFunctions.hs index 1ed674e76..fa2ec6323 100644 --- a/IHP/ServerSideComponent/ControllerFunctions.hs +++ b/IHP/ServerSideComponent/ControllerFunctions.hs @@ -45,4 +45,4 @@ setState state = do getState :: _ => _ getState = (.state) <$> readIORef ?instanceRef -deriveSSC = Aeson.deriveJSON Aeson.defaultOptions { sumEncoding = defaultTaggedObject { tagFieldName = "action", contentsFieldName = "payload" }} +deriveSSC = Aeson.deriveJSON Aeson.defaultOptions { allNullaryToStringTag = False, sumEncoding = defaultTaggedObject { tagFieldName = "action", contentsFieldName = "payload" }}