summaryrefslogtreecommitdiff
path: root/Presence/Nesting.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/Nesting.hs')
-rw-r--r--Presence/Nesting.hs12
1 files changed, 5 insertions, 7 deletions
diff --git a/Presence/Nesting.hs b/Presence/Nesting.hs
index dd0e4113..720237fd 100644
--- a/Presence/Nesting.hs
+++ b/Presence/Nesting.hs
@@ -6,7 +6,7 @@ import Data.Conduit
6import Data.Conduit.Lift 6import Data.Conduit.Lift
7import Data.XML.Types 7import Data.XML.Types
8import qualified Data.Text as S 8import qualified Data.Text as S
9import Control.Monad.State 9import Control.Monad.State.Strict
10import qualified Data.List as List 10import qualified Data.List as List
11 11
12type Lang = S.Text 12type Lang = S.Text
@@ -30,11 +30,10 @@ nesting = lift $ (return . nestingLevel) =<< get
30xmlLang :: Monad m => NestingXML o m (Maybe Lang) 30xmlLang :: Monad m => NestingXML o m (Maybe Lang)
31xmlLang = fmap (fmap snd . top . langStack) (lift get) 31xmlLang = fmap (fmap snd . top . langStack) (lift get)
32 where 32 where
33 top ( a :! as ) = Just a 33 top ( a :! _as ) = Just a
34 top _ = Nothing 34 top _ = Nothing
35 35
36 36trackNesting :: Monad m => Conduit Event (StateT XMLState m) Event
37trackNesting :: Monad m => ConduitM Event Event (StateT XMLState m) ()
38trackNesting = awaitForever doit 37trackNesting = awaitForever doit
39 where 38 where
40 doit xml = do 39 doit xml = do
@@ -61,7 +60,7 @@ lookupLang attrs =
61 60
62 61
63awaitCloser :: Monad m => Int -> NestingXML o m () 62awaitCloser :: Monad m => Int -> NestingXML o m ()
64awaitCloser lvl = do 63awaitCloser lvl =
65 fix $ \loop -> do 64 fix $ \loop -> do
66 lvl' <- nesting 65 lvl' <- nesting
67 when (lvl' >= lvl) $ do 66 when (lvl' >= lvl) $ do
@@ -80,8 +79,7 @@ nextElement = do
80 xml <- await 79 xml <- await
81 case xml of 80 case xml of
82 Nothing -> return Nothing 81 Nothing -> return Nothing
83 Just (EventBeginElement _ _) -> do 82 Just (EventBeginElement _ _) -> return xml
84 return xml
85 Just _ -> do 83 Just _ -> do
86 lvl' <- nesting 84 lvl' <- nesting
87 if (lvl'>=lvl) then loop 85 if (lvl'>=lvl) then loop