summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/DatagramServer/Types.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Network/DatagramServer/Types.hs b/src/Network/DatagramServer/Types.hs
index fea3d503..37fc40db 100644
--- a/src/Network/DatagramServer/Types.hs
+++ b/src/Network/DatagramServer/Types.hs
@@ -73,11 +73,14 @@ instance Address IP where
73 73
74 74
75 75
76type MessageClass msg = MessageClassG (QueryMethod msg) (TransactionID msg)
77 76
78newtype ReflectedIP = ReflectedIP SockAddr 77newtype ReflectedIP = ReflectedIP SockAddr
79 deriving (Eq, Ord, Show) 78 deriving (Eq, Ord, Show)
80 79
80-- The MessageClass/MessageClassG duality is merely a way to help GHC derive
81-- instances without having to cope with the QueryMethod and TransactionID type
82-- functions
83type MessageClass msg = MessageClassG (QueryMethod msg) (TransactionID msg)
81data MessageClassG meth tid = Query meth 84data MessageClassG meth tid = Query meth
82 | Response (Maybe ReflectedIP) 85 | Response (Maybe ReflectedIP)
83 | Error (KError tid) 86 | Error (KError tid)
@@ -106,6 +109,9 @@ class Envelope envelope where
106 -- Returns: response message envelope 109 -- Returns: response message envelope
107 buildReply :: NodeId envelope -> SockAddr -> envelope a -> b -> envelope b 110 buildReply :: NodeId envelope -> SockAddr -> envelope a -> b -> envelope b
108 111
112 -- This is a abstract constructor and a design wart. Since it returns into
113 -- the IO monad, it allows for outside state to be used in creating
114 -- envelopes.
109 buildQuery :: NodeId envelope -> SockAddr -> QueryMethod envelope -> TransactionID envelope -> a -> IO (envelope a) 115 buildQuery :: NodeId envelope -> SockAddr -> QueryMethod envelope -> TransactionID envelope -> a -> IO (envelope a)
110 116
111 uniqueTransactionId :: Int -> IO (TransactionID envelope) 117 uniqueTransactionId :: Int -> IO (TransactionID envelope)