xml-conduit 1.1.0.9 → 1.2.0
raw patch · 3 files changed
+20/−13 lines, 3 filesdep −failure
Dependencies removed: failure
Files
- Text/XML/Cursor.hs +6/−5
- test/main.hs +13/−6
- xml-conduit.cabal +1/−2
Text/XML/Cursor.hs view
@@ -58,10 +58,11 @@ , forceM ) where +import Control.Exception (Exception) import Control.Monad import Data.Function (on) import Text.XML-import qualified Control.Failure as F+import Control.Monad.Trans.Resource (MonadThrow, monadThrow) import qualified Data.Text as T import qualified Data.Map as Map import qualified Text.XML.Cursor.Generic as CG@@ -215,10 +216,10 @@ NodeElement (Element _ as _) -> if Just v == Map.lookup n as then [c] else [] _ -> [] -force :: F.Failure e f => e -> [a] -> f a-force e [] = F.failure e+force :: (Exception e, MonadThrow f) => e -> [a] -> f a+force e [] = monadThrow e force _ (x:_) = return x -forceM :: F.Failure e f => e -> [f a] -> f a-forceM e [] = F.failure e+forceM :: (Exception e, MonadThrow f) => e -> [f a] -> f a+forceM e [] = monadThrow e forceM _ (x:_) = x
test/main.hs view
@@ -1,8 +1,11 @@+{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} +import Control.Exception (Exception) import Control.Monad.IO.Class (liftIO)+import Data.Typeable (Typeable) import Data.XML.Types import Test.HUnit hiding (Test) import Test.Hspec@@ -301,13 +304,17 @@ (cursor $/ Cu.element "bar2" &/ Cu.element "baz2" >=> Cu.attribute "attr") @?= ["y"] null (cursor $| Cu.element "foo") @?= False cursorForce = do- Cu.force () [] @?= (Nothing :: Maybe Integer)- Cu.force () [1] @?= Just (1 :: Int)- Cu.force () [1,2] @?= Just (1 :: Int)+ Cu.force DummyEx [] @?= (Nothing :: Maybe Integer)+ Cu.force DummyEx [1] @?= Just (1 :: Int)+ Cu.force DummyEx [1,2] @?= Just (1 :: Int) cursorForceM = do- Cu.forceM () [] @?= (Nothing :: Maybe Integer)- Cu.forceM () [Just 1, Nothing] @?= Just (1 :: Int)- Cu.forceM () [Nothing, Just (1 :: Int)] @?= Nothing+ Cu.forceM DummyEx [] @?= (Nothing :: Maybe Integer)+ Cu.forceM DummyEx [Just 1, Nothing] @?= Just (1 :: Int)+ Cu.forceM DummyEx [Nothing, Just (1 :: Int)] @?= Nothing++data DummyEx = DummyEx+ deriving (Show, Typeable)+instance Exception DummyEx showEq :: (Show a, Show b) => Either a b -> Either a b -> Assertion showEq x y = show x @=? show y
xml-conduit.cabal view
@@ -1,5 +1,5 @@ name: xml-conduit-version: 1.1.0.9+version: 1.2.0 license: BSD3 license-file: LICENSE author: Michael Snoyman <michaels@suite-sol.com>, Aristid Breitkreuz <aristidb@googlemail.com>@@ -39,7 +39,6 @@ , attoparsec >= 0.10 , blaze-builder >= 0.2 && < 0.4 , transformers >= 0.2 && < 0.4- , failure >= 0.1 && < 0.3 , data-default , system-filepath >= 0.4 && < 0.5 , monad-control >= 0.3 && < 0.4