aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Reaktor/Internal.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Reaktor/Internal.hs b/src/Reaktor/Internal.hs
index bd3d241..824c57e 100644
--- a/src/Reaktor/Internal.hs
+++ b/src/Reaktor/Internal.hs
@@ -58,6 +58,15 @@ instance FromJSON Config where
data Message = Message (Maybe Text) Command [Text] | Start
deriving Show
+instance FromJSON Message where
+ parseJSON = \case
+ Object v -> do
+ mb_prefix <- v .:? "prefix"
+ cmd <- v .: "command"
+ params <- v .: "params"
+ pure (Message mb_prefix cmd params)
+ invalid -> typeMismatch "Message" invalid
+
formatMessage :: Message -> Text
formatMessage = \case
Message mb_prefix cmd params ->