summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/NestingXML.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Presence/NestingXML.hs b/Presence/NestingXML.hs
index 220e82a0..cf4fcd93 100644
--- a/Presence/NestingXML.hs
+++ b/Presence/NestingXML.hs
@@ -9,6 +9,9 @@ type NestingXML o m a = ReaderT Int (ConduitM Event o m) a
9runNestingXML :: NestingXML o m a -> Int -> ConduitM Event o m a 9runNestingXML :: NestingXML o m a -> Int -> ConduitM Event o m a
10runNestingXML = runReaderT 10runNestingXML = runReaderT
11 11
12doNestingXML :: NestingXML o m a -> ConduitM Event o m a
13doNestingXML = flip runNestingXML 0
14
12nesting :: Monad m => NestingXML o m Int 15nesting :: Monad m => NestingXML o m Int
13nesting = ask 16nesting = ask
14 17
@@ -21,6 +24,17 @@ awaitXML = do
21 _ -> id 24 _ -> id
22 local f (return xml) 25 local f (return xml)
23 26
27withXML
28 :: Monad m => (Event -> NestingXML o m ()) -> NestingXML o m ()
29withXML f = do
30 xml <- awaitXML
31 maybe (return ()) f xml
32
33maybeXML
34 :: Monad m => NestingXML o m a -> (Event -> NestingXML o m a) -> NestingXML o m a
35maybeXML whenNothing withJust = do
36 xml <- awaitXML
37 maybe whenNothing withJust xml
24 38
25awaitCloser :: Monad m => Int -> NestingXML o m () 39awaitCloser :: Monad m => Int -> NestingXML o m ()
26awaitCloser lvl = do 40awaitCloser lvl = do