Skip to content

Commit

Permalink
Refactor addBOM and addBeginEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
mniip authored and k0ral committed Mar 19, 2024
1 parent cae39c6 commit 300e25e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions xml-conduit/src/Text/XML/Stream/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down

0 comments on commit 300e25e

Please sign in to comment.