diff options
author | tv <tv@krebsco.de> | 2020-04-16 14:04:38 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2020-04-16 14:05:04 +0200 |
commit | 2bd52320dfc3bbf5d86cd74e7b76209a8cb7a330 (patch) | |
tree | 708d18cf635ce00d65400cbc653bde22c53921e8 /src/Reaktor/Internal.hs | |
parent | 9f4e2644188f985d7cd806c13e2c0dee1688b9f0 (diff) |
Reaktor.Internal: add FromJSON Message
Diffstat (limited to 'src/Reaktor/Internal.hs')
-rw-r--r-- | src/Reaktor/Internal.hs | 9 |
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 -> |