list-t-attoparsec 0.2.0.0 → 0.3.0.0
raw patch · 2 files changed
+12/−12 lines, 2 filesdep +eitherdep +transformersdep −exceptionsdep −mtl-preludePVP ok
version bump matches the API change (PVP)
Dependencies added: either, transformers
Dependencies removed: exceptions, mtl-prelude
API changes (from Hackage documentation)
- ListT.Attoparsec: ParsingFailure :: !String -> ![String] -> ParsingFailure
- ListT.Attoparsec: data ParsingFailure
- ListT.Attoparsec: instance Constructor C1_0ParsingFailure
- ListT.Attoparsec: instance Data ParsingFailure
- ListT.Attoparsec: instance Datatype D1ParsingFailure
- ListT.Attoparsec: instance Eq ParsingFailure
- ListT.Attoparsec: instance Exception ParsingFailure
- ListT.Attoparsec: instance Generic ParsingFailure
- ListT.Attoparsec: instance Ord ParsingFailure
- ListT.Attoparsec: instance Show ParsingFailure
- ListT.Attoparsec: instance Typeable ParsingFailure
+ ListT.Attoparsec: Error :: !String -> ![String] -> Error
+ ListT.Attoparsec: data Error
+ ListT.Attoparsec: instance Constructor C1_0Error
+ ListT.Attoparsec: instance Data Error
+ ListT.Attoparsec: instance Datatype D1Error
+ ListT.Attoparsec: instance Eq Error
+ ListT.Attoparsec: instance Generic Error
+ ListT.Attoparsec: instance Ord Error
+ ListT.Attoparsec: instance Show Error
+ ListT.Attoparsec: instance Typeable Error
- ListT.Attoparsec: textParser :: MonadThrow m => Parser a -> Transformation m Text a
+ ListT.Attoparsec: textParser :: Monad m => Parser a -> ListT m Text -> ListT (EitherT Error m) a
Files
library/ListT/Attoparsec.hs view
@@ -1,8 +1,9 @@ module ListT.Attoparsec where import BasePrelude hiding (cons, uncons)-import MTLPrelude-import Control.Monad.Catch+import Control.Monad.Trans.Either+import Control.Monad.Trans.Class+import Data.Either.Combinators import Data.Text (Text) import ListT import qualified Data.Attoparsec.Text as P@@ -11,22 +12,21 @@ -- | -- A text message and a list of contexts, -- as per the failure in \"attoparsec\".-data ParsingFailure =- ParsingFailure !String ![String]+data Error =+ Error !String ![String] deriving (Show, Eq, Ord, Data, Typeable, Generic) -instance Exception ParsingFailure -- | -- Given a text parser, produces -- a transformation of a stream of text chunks into a stream of parsed results.--- In case of a parsing failure it raises a 'ParsingFailure' error in the base monad.-textParser :: MonadThrow m => P.Parser a -> Transformation m Text a+-- In case of a parsing failure it raises an 'Error' in the 'EitherT' monad over the base.+textParser :: Monad m => P.Parser a -> ListT m Text -> ListT (EitherT Error m) a textParser p = loop (P.parse p) where loop parse input =- lift (uncons input) >>= maybe mzero (onUncons parse)+ lift (lift (uncons input)) >>= maybe mzero (onUncons parse) onUncons parse (chunk, otherChunks) = case parse chunk of P.Done chunk' result -> @@ -34,6 +34,6 @@ P.Partial parse' -> loop parse' otherChunks P.Fail _ contexts message -> - lift $ throwM $ ParsingFailure message contexts+ lift $ EitherT $ return $ Left $ Error message contexts
list-t-attoparsec.cabal view
@@ -1,7 +1,7 @@ name: list-t-attoparsec version:- 0.2.0.0+ 0.3.0.0 synopsis: An "attoparsec" adapter for "list-t" category:@@ -49,6 +49,6 @@ attoparsec >= 0.10 && < 0.13, text >= 1 && < 1.3, list-t == 0.4.*,- exceptions == 0.8.*,- mtl-prelude >= 1 && < 3,+ either == 4.*,+ transformers >= 0.3 && < 0.5, base-prelude >= 0.1.19 && < 0.2