summaryrefslogtreecommitdiff
path: root/src/Network/QueryResponse.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/QueryResponse.hs')
-rw-r--r--src/Network/QueryResponse.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Network/QueryResponse.hs b/src/Network/QueryResponse.hs
index 1901e164..9563fa7c 100644
--- a/src/Network/QueryResponse.hs
+++ b/src/Network/QueryResponse.hs
@@ -27,6 +27,7 @@ import qualified Data.IntMap.Strict as IntMap
27 ;import Data.IntMap.Strict (IntMap) 27 ;import Data.IntMap.Strict (IntMap)
28import qualified Data.Map.Strict as Map 28import qualified Data.Map.Strict as Map
29 ;import Data.Map.Strict (Map) 29 ;import Data.Map.Strict (Map)
30import qualified Data.Word64Map as W64Map
30import Data.Maybe 31import Data.Maybe
31import Data.Typeable 32import Data.Typeable
32import Network.Socket 33import Network.Socket
@@ -128,6 +129,10 @@ partitionTransportM parse encodex tr = do
128 } 129 }
129 return (xtr, ytr) 130 return (xtr, ytr)
130 131
132-- |
133-- * f add x --> Nothing, consume x
134-- --> Just id, leave x to a different handler
135-- --> Just g, apply g to x and leave that to a different handler
131addHandler :: ErrorReporter addr x meth tid err -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x 136addHandler :: ErrorReporter addr x meth tid err -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x
132addHandler err f tr = tr 137addHandler err f tr = tr
133 { awaitMessage = \kont -> fix $ \eat -> awaitMessage tr $ \m -> do 138 { awaitMessage = \kont -> fix $ \eat -> awaitMessage tr $ \m -> do
@@ -304,7 +309,7 @@ data TransactionMethods d tid addr x = TransactionMethods
304 dispatchRegister :: MVar x -> addr -> d -> STM (tid, d) 309 dispatchRegister :: MVar x -> addr -> d -> STM (tid, d)
305 -- | This method is invoked when an incoming packet /x/ indicates it is 310 -- | This method is invoked when an incoming packet /x/ indicates it is
306 -- a response to the transaction with id /tid/. The returned IO action 311 -- a response to the transaction with id /tid/. The returned IO action
307 -- is will write the packet to the correct 'MVar' thus completing the 312 -- will write the packet to the correct 'MVar' thus completing the
308 -- dispatch. 313 -- dispatch.
309 , dispatchResponse :: tid -> x -> d -> STM (d, IO ()) 314 , dispatchResponse :: tid -> x -> d -> STM (d, IO ())
310 -- | When a timeout interval elapses, this method is called to remove the 315 -- | When a timeout interval elapses, this method is called to remove the
@@ -323,10 +328,14 @@ data TableMethods t tid = TableMethods
323 , tblLookup :: forall a. tid -> t a -> Maybe a 328 , tblLookup :: forall a. tid -> t a -> Maybe a
324 } 329 }
325 330
326-- | Methods for using 'Data.IntMap. 331-- | Methods for using 'Data.IntMap'.
327intMapMethods :: TableMethods IntMap Int 332intMapMethods :: TableMethods IntMap Int
328intMapMethods = TableMethods IntMap.insert IntMap.delete IntMap.lookup 333intMapMethods = TableMethods IntMap.insert IntMap.delete IntMap.lookup
329 334
335-- | Methods for using 'Data.Word64Map'.
336w64MapMethods :: TableMethods IntMap Int
337w64MapMethods = TableMethods W64Map.insert W64Map.delete W64Map.lookup
338
330-- | Methods for using 'Data.Map' 339-- | Methods for using 'Data.Map'
331mapMethods :: Ord tid => TableMethods (Map tid) tid 340mapMethods :: Ord tid => TableMethods (Map tid) tid
332mapMethods = TableMethods Map.insert Map.delete Map.lookup 341mapMethods = TableMethods Map.insert Map.delete Map.lookup