list-t-attoparsec 0.3.1.1 → 0.4.0.0
raw patch · 2 files changed
+9/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- ListT.Attoparsec: Error :: !String -> ![String] -> Error
- ListT.Attoparsec: consumeOne :: Monad m => Parser a -> ListT m Text -> m (Either Error (a, ListT m Text))
- 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 :: Monad m => Parser a -> ListT m Text -> ListT (EitherT Error m) a
+ ListT.Attoparsec: consume :: Monad m => Parser a -> ListT m Text -> m (Either Error (a, ListT m Text))
+ ListT.Attoparsec: stream :: Monad m => Parser a -> ListT m Text -> ListT (EitherT Error m) a
+ ListT.Attoparsec: type Error = (Text, [Text])
Files
library/ListT/Attoparsec.hs view
@@ -13,17 +13,16 @@ -- | -- A text message and a list of contexts, -- as per the failure in \"attoparsec\".-data Error =- Error !String ![String]- deriving (Show, Eq, Ord, Data, Typeable, Generic)+type Error =+ (Text, [Text]) -- | -- 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 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 =+stream :: Monad m => P.Parser a -> ListT m Text -> ListT (EitherT Error m) a+stream p = loop (P.parse p) where loop parse input =@@ -35,13 +34,13 @@ P.Partial parse' -> loop parse' otherChunks P.Fail _ contexts message -> - lift $ EitherT $ return $ Left $ Error message contexts+ lift $ EitherT $ return $ Left $ (,) (T.pack message) (map T.pack contexts) -- | -- Consume only as much input as needed to run the provided parser once. -- Results in either a failure or the parsed result and the leftover stream.-consumeOne :: Monad m => P.Parser a -> ListT m Text -> m (Either Error (a, ListT m Text))-consumeOne =+consume :: Monad m => P.Parser a -> ListT m Text -> m (Either Error (a, ListT m Text))+consume = \p -> loop (P.parse p) where loop parse stream =@@ -59,4 +58,4 @@ P.Partial parse' -> loop parse' streamRemainder P.Fail _ contexts message ->- return $ Left $ Error message contexts+ return $ Left $ (,) (T.pack message) (map T.pack contexts)
list-t-attoparsec.cabal view
@@ -1,7 +1,7 @@ name: list-t-attoparsec version:- 0.3.1.1+ 0.4.0.0 synopsis: An "attoparsec" adapter for "list-t" category: