packages feed

xml-conduit 1.1.0.2 → 1.1.0.3

raw patch · 3 files changed

+36/−11 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Text.XML.Stream.Parse: force :: MonadThrow m => String -> Consumer Event m (Maybe a) -> Consumer Event m a
+ Text.XML.Stream.Parse: force :: MonadThrow m => String -> ConduitM Event o m (Maybe a) -> ConduitM Event o m a
- Text.XML.Stream.Parse: tag :: MonadThrow m => (Name -> Maybe a) -> (a -> AttrParser b) -> (b -> Consumer Event m c) -> Consumer Event m (Maybe c)
+ Text.XML.Stream.Parse: tag :: MonadThrow m => (Name -> Maybe a) -> (a -> AttrParser b) -> (b -> ConduitM Event o m c) -> ConduitM Event o m (Maybe c)
- Text.XML.Stream.Parse: tagName :: MonadThrow m => Name -> AttrParser a -> (a -> Consumer Event m b) -> Consumer Event m (Maybe b)
+ Text.XML.Stream.Parse: tagName :: MonadThrow m => Name -> AttrParser a -> (a -> ConduitM Event o m b) -> ConduitM Event o m (Maybe b)
- Text.XML.Stream.Parse: tagNoAttr :: MonadThrow m => Name -> Consumer Event m a -> Consumer Event m (Maybe a)
+ Text.XML.Stream.Parse: tagNoAttr :: MonadThrow m => Name -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
- Text.XML.Stream.Parse: tagPredicate :: MonadThrow m => (Name -> Bool) -> AttrParser a -> (a -> Consumer Event m b) -> Consumer Event m (Maybe b)
+ Text.XML.Stream.Parse: tagPredicate :: MonadThrow m => (Name -> Bool) -> AttrParser a -> (a -> ConduitM Event o m b) -> ConduitM Event o m (Maybe b)

Files

Text/XML/Stream/Parse.hs view
@@ -116,6 +116,7 @@ import Data.Conduit import qualified Data.Conduit.Text as CT import qualified Data.Conduit.List as CL+import qualified Data.Conduit.Internal as CI import Control.Monad (ap, liftM) import qualified Data.Text as TS import Data.List (foldl')@@ -521,8 +522,8 @@ tag :: MonadThrow m     => (Name -> Maybe a)     -> (a -> AttrParser b)-    -> (b -> Consumer Event m c)-    -> Consumer Event m (Maybe c)+    -> (b -> CI.ConduitM Event o m c)+    -> CI.ConduitM Event o m (Maybe c) tag checkName attrParser f = do     x <- dropWS     case x of@@ -571,8 +572,8 @@ tagPredicate :: MonadThrow m              => (Name -> Bool)              -> AttrParser a-             -> (a -> Consumer Event m b)-             -> Consumer Event m (Maybe b)+             -> (a -> CI.ConduitM Event o m b)+             -> CI.ConduitM Event o m (Maybe b) tagPredicate p attrParser = tag (\x -> if p x then Just () else Nothing) (const attrParser)  -- | A simplified version of 'tag' which matches for specific tag names instead@@ -582,15 +583,15 @@ tagName :: MonadThrow m      => Name      -> AttrParser a-     -> (a -> Consumer Event m b)-     -> Consumer Event m (Maybe b)+     -> (a -> CI.ConduitM Event o m b)+     -> CI.ConduitM Event o m (Maybe b) tagName name = tagPredicate (== name)  -- | A further simplified tag parser, which requires that no attributes exist. tagNoAttr :: MonadThrow m           => Name-          -> Consumer Event m a-          -> Consumer Event m (Maybe a)+          -> CI.ConduitM Event o m a+          -> CI.ConduitM Event o m (Maybe a) tagNoAttr name f = tagName name (return ()) $ const f  -- | Get the value of the first parser which returns 'Just'. If no parsers@@ -624,8 +625,8 @@ -- want to finally force something to happen. force :: MonadThrow m       => String -- ^ Error message-      -> Consumer Event m (Maybe a)-      -> Consumer Event m a+      -> CI.ConduitM Event o m (Maybe a)+      -> CI.ConduitM Event o m a force msg i = do     x <- i     case x of
test/main.hs view
@@ -17,11 +17,13 @@ import Text.XML.Cursor ((&/), (&//), (&.//), ($|), ($/), ($//), ($.//)) import Data.Text(Text) import Control.Monad+import Control.Monad.Trans.Class (lift) import qualified Data.Text as T import qualified Data.Set as Set import Control.Exception (toException)  import qualified Data.Conduit as C+import qualified Data.Conduit.List as CL import qualified Data.Map as Map import Text.Blaze (toMarkup) import Text.Blaze.Renderer.String (renderMarkup)@@ -38,6 +40,7 @@         it "ignores the BOM" parseIgnoreBOM         it "strips duplicated attributes" stripDuplicateAttributes         it "displays comments" testRenderComments+        it "conduit parser" testConduitParser     describe "XML Cursors" $ do         it "has correct parent" cursorParent         it "has correct ancestor" cursorAncestor@@ -189,6 +192,27 @@         , "<success/>"         , "</hello>"         ]++testConduitParser :: Assertion+testConduitParser = C.runResourceT $ do+    x <- P.parseLBS def input+        C.$= (P.force "need hello" $ P.tagNoAttr "hello" f)+        C.$$ CL.consume+    liftIO $ x @?= [1, 1, 1]+  where+    input = L.concat+        [ "<?xml version='1.0'?>"+        , "<!DOCTYPE foo []>\n"+        , "<hello>"+        , "<item/>"+        , "<item/>"+        , "<item/>"+        , "</hello>"+        ]+    f :: C.MonadThrow m => C.Conduit Event m Int+    f = do+        ma <- P.tagNoAttr "item" (return 1)+        maybe (return ()) (\a -> C.yield a >> f) ma   name :: [Cu.Cursor] -> [Text]
xml-conduit.cabal view
@@ -1,5 +1,5 @@ name:            xml-conduit-version:         1.1.0.2+version:         1.1.0.3 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michaels@suite-sol.com>, Aristid Breitkreuz <aristidb@googlemail.com>