From dd6008a55470b02282c6eaddfb66eafda76e023e Mon Sep 17 00:00:00 2001 From: mniip Date: Fri, 15 Mar 2024 11:45:48 +0100 Subject: [PATCH] Refactor addBOM and addBeginEnd --- xml-conduit/src/Text/XML/Stream/Parse.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xml-conduit/src/Text/XML/Stream/Parse.hs b/xml-conduit/src/Text/XML/Stream/Parse.hs index d30ea1c..31be337 100644 --- a/xml-conduit/src/Text/XML/Stream/Parse.hs +++ b/xml-conduit/src/Text/XML/Stream/Parse.hs @@ -390,8 +390,7 @@ dropBOM = let output | c == '\xfeef' = cs | otherwise = t - in yield output >> idConduit - idConduit = await >>= maybe (return ()) (\x -> yield x >> idConduit) + in yield output >> awaitForever yield -- | Parses a character stream into 'Event's. This function is implemented -- fully in Haskell using attoparsec-text for parsing. The produced error @@ -417,10 +416,10 @@ parseTextPos de = .| addBeginEnd where tokenize = conduitToken de - addBeginEnd = yield (Nothing, EventBeginDocument) >> addEnd - addEnd = await >>= maybe - (yield (Nothing, EventEndDocument)) - (\e -> yield e >> addEnd) + addBeginEnd = do + yield (Nothing, EventBeginDocument) + awaitForever yield + yield (Nothing, EventEndDocument) toEventC :: Monad m => ParseSettings -> ConduitT (PositionRange, Token) EventPos m () toEventC ps =