diff options
Diffstat (limited to 'src/Network/QueryResponse.hs')
-rw-r--r-- | src/Network/QueryResponse.hs | 13 |
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) |
28 | import qualified Data.Map.Strict as Map | 28 | import qualified Data.Map.Strict as Map |
29 | ;import Data.Map.Strict (Map) | 29 | ;import Data.Map.Strict (Map) |
30 | import qualified Data.Word64Map as W64Map | ||
30 | import Data.Maybe | 31 | import Data.Maybe |
31 | import Data.Typeable | 32 | import Data.Typeable |
32 | import Network.Socket | 33 | import 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 | ||
131 | addHandler :: ErrorReporter addr x meth tid err -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x | 136 | addHandler :: ErrorReporter addr x meth tid err -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x |
132 | addHandler err f tr = tr | 137 | addHandler 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'. |
327 | intMapMethods :: TableMethods IntMap Int | 332 | intMapMethods :: TableMethods IntMap Int |
328 | intMapMethods = TableMethods IntMap.insert IntMap.delete IntMap.lookup | 333 | intMapMethods = TableMethods IntMap.insert IntMap.delete IntMap.lookup |
329 | 334 | ||
335 | -- | Methods for using 'Data.Word64Map'. | ||
336 | w64MapMethods :: TableMethods IntMap Int | ||
337 | w64MapMethods = TableMethods W64Map.insert W64Map.delete W64Map.lookup | ||
338 | |||
330 | -- | Methods for using 'Data.Map' | 339 | -- | Methods for using 'Data.Map' |
331 | mapMethods :: Ord tid => TableMethods (Map tid) tid | 340 | mapMethods :: Ord tid => TableMethods (Map tid) tid |
332 | mapMethods = TableMethods Map.insert Map.delete Map.lookup | 341 | mapMethods = TableMethods Map.insert Map.delete Map.lookup |