diff options
Diffstat (limited to 'Presence/XMLToByteStrings.hs')
-rw-r--r-- | Presence/XMLToByteStrings.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Presence/XMLToByteStrings.hs b/Presence/XMLToByteStrings.hs index d8d2e965..92ac05cd 100644 --- a/Presence/XMLToByteStrings.hs +++ b/Presence/XMLToByteStrings.hs | |||
@@ -1,5 +1,7 @@ | |||
1 | {-# LANGUAGE CPP #-} | 1 | {-# LANGUAGE CPP #-} |
2 | module XMLToByteStrings (xmlToByteStrings) where | 2 | module XMLToByteStrings |
3 | ( xmlToByteStrings | ||
4 | , prettyPrint ) where | ||
3 | 5 | ||
4 | import Control.Monad.IO.Class | 6 | import Control.Monad.IO.Class |
5 | import Control.Monad.Trans.Class | 7 | import Control.Monad.Trans.Class |
@@ -8,13 +10,15 @@ import Control.Monad.Fix | |||
8 | import Control.Monad (when) | 10 | import Control.Monad (when) |
9 | import Data.Conduit | 11 | import Data.Conduit |
10 | import qualified Data.Conduit.List as CL | 12 | import qualified Data.Conduit.List as CL |
13 | import qualified Data.Conduit.Binary as CB | ||
11 | import Data.XML.Types as XML (Event) | 14 | import Data.XML.Types as XML (Event) |
12 | import qualified Data.ByteString as S (ByteString) | 15 | import qualified Data.ByteString as S (ByteString,append) |
16 | import qualified Data.ByteString.Char8 as S (putStrLn) | ||
13 | #ifdef RENDERFLUSH | 17 | #ifdef RENDERFLUSH |
14 | import Data.Conduit.Blaze (builderToByteStringFlush) | 18 | import Data.Conduit.Blaze (builderToByteStringFlush) |
15 | import Text.XML.Stream.Render (def,renderBuilderFlush) | 19 | import Text.XML.Stream.Render (def,renderBuilderFlush,renderBytes,rsPretty) |
16 | #else | 20 | #else |
17 | import Text.XML.Stream.Render (def,renderBytes) | 21 | import Text.XML.Stream.Render (def,renderBytes,rsPretty) |
18 | #endif | 22 | #endif |
19 | 23 | ||
20 | fixMaybeT f = (>> return ()) . runMaybeT . fix $ f | 24 | fixMaybeT f = (>> return ()) . runMaybeT . fix $ f |
@@ -62,3 +66,7 @@ renderChunks = fixMaybeT $ \loop -> do | |||
62 | loop | 66 | loop |
63 | #endif | 67 | #endif |
64 | 68 | ||
69 | |||
70 | prettyPrint prefix xs = | ||
71 | liftIO $ do | ||
72 | CL.sourceList xs $= renderBytes (def { rsPretty=True }) =$= CB.lines $$ CL.mapM_ (S.putStrLn . (prefix `S.append`)) | ||