diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/NestingXML.hs | 14 |
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 | |||
9 | runNestingXML :: NestingXML o m a -> Int -> ConduitM Event o m a | 9 | runNestingXML :: NestingXML o m a -> Int -> ConduitM Event o m a |
10 | runNestingXML = runReaderT | 10 | runNestingXML = runReaderT |
11 | 11 | ||
12 | doNestingXML :: NestingXML o m a -> ConduitM Event o m a | ||
13 | doNestingXML = flip runNestingXML 0 | ||
14 | |||
12 | nesting :: Monad m => NestingXML o m Int | 15 | nesting :: Monad m => NestingXML o m Int |
13 | nesting = ask | 16 | nesting = 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 | ||
27 | withXML | ||
28 | :: Monad m => (Event -> NestingXML o m ()) -> NestingXML o m () | ||
29 | withXML f = do | ||
30 | xml <- awaitXML | ||
31 | maybe (return ()) f xml | ||
32 | |||
33 | maybeXML | ||
34 | :: Monad m => NestingXML o m a -> (Event -> NestingXML o m a) -> NestingXML o m a | ||
35 | maybeXML whenNothing withJust = do | ||
36 | xml <- awaitXML | ||
37 | maybe whenNothing withJust xml | ||
24 | 38 | ||
25 | awaitCloser :: Monad m => Int -> NestingXML o m () | 39 | awaitCloser :: Monad m => Int -> NestingXML o m () |
26 | awaitCloser lvl = do | 40 | awaitCloser lvl = do |