diff options
author | Andrew Cady <d@jerkface.net> | 2016-02-23 12:39:08 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-02-23 12:39:08 -0500 |
commit | aad209be278b2c6b96c461d6d7b221b29bd964cc (patch) | |
tree | d45aeade56f69cc2c56f376d3f02e74e4facc1a4 | |
parent | 2191e88da4b3cace8d30ac91854a1e566c6bb7b2 (diff) |
avoid forked xml-conduit
turns out it wasn't necessary
-rw-r--r-- | Presence/XMPPServer.hs | 14 | ||||
-rw-r--r-- | stack.yaml | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 8845ea72..08e0b8c3 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -248,6 +248,18 @@ wlog s = putStrLn s >> hFlush stdout | |||
248 | wlogb :: ByteString -> IO () | 248 | wlogb :: ByteString -> IO () |
249 | wlogb s = Strict8.putStrLn s >> hFlush stdout | 249 | wlogb s = Strict8.putStrLn s >> hFlush stdout |
250 | 250 | ||
251 | flushPassThrough :: Monad m => Conduit a m b -> Conduit (Flush a) m (Flush b) | ||
252 | flushPassThrough c = getZipConduit $ ZipConduit (onlyChunks =$= mapOutput Chunk c) <* ZipConduit onlyFlushes | ||
253 | where | ||
254 | onlyChunks :: Monad m => Conduit (Flush a) m a | ||
255 | onlyFlushes :: Monad m => Conduit (Flush a) m (Flush b) | ||
256 | onlyChunks = awaitForever yieldChunk | ||
257 | onlyFlushes = awaitForever yieldFlush | ||
258 | yieldFlush Flush = yield Flush | ||
259 | yieldFlush _ = return () | ||
260 | yieldChunk (Chunk x) = yield x | ||
261 | yieldChunk _ = return () | ||
262 | |||
251 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event | 263 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event |
252 | , Sink (Flush XML.Event) IO () ) | 264 | , Sink (Flush XML.Event) IO () ) |
253 | xmlStream conread conwrite = (xsrc,xsnk) | 265 | xmlStream conread conwrite = (xsrc,xsnk) |
@@ -255,7 +267,7 @@ xmlStream conread conwrite = (xsrc,xsnk) | |||
255 | xsrc = src $= XML.parseBytes XML.def | 267 | xsrc = src $= XML.parseBytes XML.def |
256 | xsnk :: Sink (Flush Event) IO () | 268 | xsnk :: Sink (Flush Event) IO () |
257 | xsnk = -- XML.renderBytes XML.def =$ snk | 269 | xsnk = -- XML.renderBytes XML.def =$ snk |
258 | XML.renderBuilderFlush XML.def | 270 | flushPassThrough (XML.renderBuilder XML.def) |
259 | =$= builderToByteStringFlush | 271 | =$= builderToByteStringFlush |
260 | =$= discardFlush | 272 | =$= discardFlush |
261 | =$ snk | 273 | =$ snk |
@@ -7,12 +7,6 @@ resolver: lts-5.4 | |||
7 | # Local packages, usually specified by relative directory name | 7 | # Local packages, usually specified by relative directory name |
8 | packages: | 8 | packages: |
9 | - '.' | 9 | - '.' |
10 | - location: | ||
11 | git: git@github.com:afcady/xml.git | ||
12 | commit: 3096cfd59ea95944fab4b0af26e1722863f02090 | ||
13 | subdirs: | ||
14 | - xml-conduit | ||
15 | extra-dep: true | ||
16 | # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) | 10 | # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) |
17 | extra-deps: [] | 11 | extra-deps: [] |
18 | 12 | ||