summaryrefslogtreecommitdiff
path: root/src/Network/RPC.hs
blob: 2e9356e8dc2790436b0b04580c735f6ba4f9c677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{-# LANGUAGE RankNTypes #-}
module Network.RPC where

import Data.ByteString (ByteString)

data MessageClass = Error | Query | Response
 deriving (Eq,Ord,Enum,Bounded,Show,Read)

data Messaging msg tid payload = Messaging
    { messageClass       :: forall a. msg a -> MessageClass
    , messageTransaction :: forall a. msg a -> tid
    , messagePayload     :: forall a. msg a -> a
    , encodePayload      :: msg payload -> msg ByteString
    , decodePayload      :: msg ByteString -> Either String (msg payload)
    }