diff options
Diffstat (limited to 'src/Network/QueryResponse.hs')
-rw-r--r-- | src/Network/QueryResponse.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Network/QueryResponse.hs b/src/Network/QueryResponse.hs index 492b7bb4..f15a0855 100644 --- a/src/Network/QueryResponse.hs +++ b/src/Network/QueryResponse.hs | |||
@@ -135,18 +135,18 @@ partitionTransportM parse encodex tr = do | |||
135 | -- * f add x --> Nothing, consume x | 135 | -- * f add x --> Nothing, consume x |
136 | -- --> Just id, leave x to a different handler | 136 | -- --> Just id, leave x to a different handler |
137 | -- --> Just g, apply g to x and leave that to a different handler | 137 | -- --> Just g, apply g to x and leave that to a different handler |
138 | addHandler :: ErrorReporter addr x meth tid err -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x | 138 | addHandler :: (err -> IO ()) -> (addr -> x -> IO (Maybe (x -> x))) -> Transport err addr x -> Transport err addr x |
139 | addHandler err f tr = tr | 139 | addHandler onParseError f tr = tr |
140 | { awaitMessage = \kont -> fix $ \eat -> awaitMessage tr $ \m -> do | 140 | { awaitMessage = \kont -> fix $ \eat -> awaitMessage tr $ \m -> do |
141 | case m of | 141 | case m of |
142 | Just (Right (x, addr)) -> f addr x >>= maybe eat (kont . Just . Right . (, addr) . ($ x)) | 142 | Just (Right (x, addr)) -> f addr x >>= maybe eat (kont . Just . Right . (, addr) . ($ x)) |
143 | Just (Left e ) -> reportParseError err e >> kont (Just $ Left e) | 143 | Just (Left e ) -> onParseError e >> kont (Just $ Left e) |
144 | Nothing -> kont $ Nothing | 144 | Nothing -> kont $ Nothing |
145 | } | 145 | } |
146 | 146 | ||
147 | -- | Modify a 'Transport' to invoke an action upon every received packet. | 147 | -- | Modify a 'Transport' to invoke an action upon every received packet. |
148 | onInbound :: (addr -> x -> IO ()) -> Transport err addr x -> Transport err addr x | 148 | onInbound :: (addr -> x -> IO ()) -> Transport err addr x -> Transport err addr x |
149 | onInbound f tr = addHandler ignoreErrors (\addr x -> f addr x >> return (Just id)) tr | 149 | onInbound f tr = addHandler (const $ return ()) (\addr x -> f addr x >> return (Just id)) tr |
150 | 150 | ||
151 | -- * Using a query\/response client. | 151 | -- * Using a query\/response client. |
152 | 152 | ||