-
Notifications
You must be signed in to change notification settings - Fork 0
/
Message.hs
34 lines (28 loc) · 1.03 KB
/
Message.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE TemplateHaskell, OverloadedStrings, NamedFieldPuns #-}
module Message where
import JsonInstances
import JsonUtils
import Data.Aeson
import Data.Aeson.TH
import Data.Int (Int64)
import Data.Text
import Language.Haskell.TH
data ClientMessage
= ClientFCall { cFunName :: Name
, cFunId :: Int64
, cFunArgs :: [Value] }
| LOLOLOLOLOL
deriving (Show)
data ServerMessage
= ServerFunctionReturn { sFunId :: Int64
, sRetVal :: Value }
| LOLOLOLOLOAL
deriving (Show)
-- TODO TH
instance ToJSON ServerMessage where
toJSON (ServerFunctionReturn { sFunId, sRetVal })
= constr "ServerFunctionReturn" $ object [ "sFunId" .= toJSON sFunId
, "sRetVal" .= toJSON sRetVal
]
$(deriveToJSON id ''ClientMessage)
$(deriveFromJSON id ''ClientMessage)