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