-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathExampleClockTypes.hs
37 lines (31 loc) · 1.14 KB
/
ExampleClockTypes.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
35
36
37
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module ExampleClockTypes
( ClockConfig (..)
, ClockResult (..)
) where
import Data.Aeson as JSON (FromJSON (..), ToJSON (..))
import GHC.Generics (Generic)
import qualified System.MQ.Encoding.JSON as JSON (pack, unpack)
import System.MQ.Protocol (MessageLike (..), MessageType (..),
Props (..), jsonEncoding)
-- | 'ClockConfig' represents configuration data for clock.
--
newtype ClockConfig = ClockConfig { question :: String }
deriving (Show, Generic)
instance ToJSON ClockConfig
instance FromJSON ClockConfig
instance MessageLike ClockConfig where
props = Props "example_clock" Config jsonEncoding
pack = JSON.pack
unpack = JSON.unpack
-- | 'ClockResult' represents result data produced by clock example.
--
newtype ClockResult = ClockResult { answer :: Int }
deriving (Show, Generic)
instance ToJSON ClockResult
instance FromJSON ClockResult
instance MessageLike ClockResult where
props = Props "example_clock" Result jsonEncoding
pack = JSON.pack
unpack = JSON.unpack