packages feed

attoparsec 0.10.0.3 → 0.10.1.0

raw patch · 8 files changed

+11/−220 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.Attoparsec.ByteString.Char8: Done :: t -> r -> IResult t r
+ Data.Attoparsec.ByteString.Char8: Fail :: t -> [String] -> String -> IResult t r
+ Data.Attoparsec.ByteString.Char8: Partial :: (t -> IResult t r) -> IResult t r
+ Data.Attoparsec.ByteString.Char8: data IResult t r
- Data.Attoparsec.ByteString: type Parser a = Parser ByteString a
+ Data.Attoparsec.ByteString: type Parser = Parser ByteString
- Data.Attoparsec.ByteString: type Result a = IResult ByteString a
+ Data.Attoparsec.ByteString: type Result = IResult ByteString
- Data.Attoparsec.ByteString.Char8: type Parser a = Parser ByteString a
+ Data.Attoparsec.ByteString.Char8: type Parser = Parser ByteString
- Data.Attoparsec.ByteString.Char8: type Result a = IResult ByteString a
+ Data.Attoparsec.ByteString.Char8: type Result = IResult ByteString
- Data.Attoparsec.Text: type Parser a = Parser Text a
+ Data.Attoparsec.Text: type Parser = Parser Text
- Data.Attoparsec.Text: type Result a = IResult Text a
+ Data.Attoparsec.Text: type Result = IResult Text

Files

Data/Attoparsec/ByteString/Char8.hs view
@@ -21,6 +21,7 @@     -- * Parser types       Parser     , A.Result+    , A.IResult(..)      -- * Running parsers     , A.parse
Data/Attoparsec/ByteString/Internal.hs view
@@ -83,8 +83,8 @@ import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Unsafe as B -type Parser a = T.Parser B.ByteString a-type Result a = IResult B.ByteString a+type Parser = T.Parser B.ByteString+type Result = IResult B.ByteString type Input = T.Input B.ByteString type Added = T.Added B.ByteString type Failure r = T.Failure B.ByteString r
Data/Attoparsec/Text/Internal.hs view
@@ -72,8 +72,8 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as L -type Parser a = T.Parser Text a-type Result a = IResult Text a+type Parser = T.Parser Text+type Result = IResult Text type Input = T.Input Text type Added = T.Added Text type Failure r = T.Failure Text r
attoparsec.cabal view
@@ -1,5 +1,5 @@ name:            attoparsec-version:         0.10.0.3+version:         0.10.1.0 license:         BSD3 license-file:    LICENSE category:        Text, Parsing
benchmarks/Tiny.hs view
@@ -1,7 +1,7 @@-import Control.Applicative ((<|>))+import Control.Applicative ((<|>), many) import Control.Monad (forM_) import System.Environment (getArgs)-import qualified Data.Attoparsec.Char8 as A+import qualified Data.Attoparsec.ByteString.Char8 as A import qualified Data.ByteString.Char8 as B import qualified Text.Parsec as P import qualified Text.Parsec.ByteString as P@@ -14,8 +14,8 @@       A.Done _ xs -> print (length xs)       what        -> print what  where-  slow = A.many (A.many1 A.letter_ascii <|> A.many1 A.digit)-  fast = A.many (A.takeWhile1 isLetter <|> A.takeWhile1 isDigit)+  slow = many (A.many1 A.letter_ascii <|> A.many1 A.digit)+  fast = many (A.takeWhile1 isLetter <|> A.takeWhile1 isDigit)   isDigit c  = c >= '0' && c <= '9'   isLetter c = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')   p = fast
examples/RFC2616.hs view
@@ -15,7 +15,7 @@     , lookupHeader     ) where -import Control.Applicative hiding (many)+import Control.Applicative import Data.Attoparsec as P import qualified Data.Attoparsec.Char8 as P8 import Data.Attoparsec.Char8 (char8, endOfLine, isDigit_w8)
− tests/QC/ByteString.hs
@@ -1,105 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-module QC.ByteString (tests) where--import Control.Applicative ((<$>))-import Prelude hiding (takeWhile)-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.QuickCheck-import qualified Data.Attoparsec.ByteString as P-import qualified Data.Attoparsec.ByteString.Lazy as PL-import qualified Data.ByteString as B-import qualified Data.ByteString.Lazy as L--instance Arbitrary B.ByteString where-    arbitrary   = B.pack <$> arbitrary--instance Arbitrary L.ByteString where-    arbitrary   = sized $ \n -> resize (round (sqrt (toEnum n :: Double)))-                  ((L.fromChunks . map (B.pack . nonEmpty)) <$> arbitrary)-      where nonEmpty (NonEmpty a) = a---- Naming.--{--label (NonEmpty s) = case parse (anyWord8 <?> s) B.empty of-                            (_, Left err) -> s `isInfixOf` err-                            _             -> False--}---- Basic byte-level combinators.--maybeP p = PL.maybeResult . PL.parse p--defP p = PL.parse p--satisfy w s = maybeP (P.satisfy (<=w)) (L.cons w s) == Just w--word8 w s = maybeP (P.word8 w) (L.cons w s) == Just w--anyWord8 s-    | L.null s  = p == Nothing-    | otherwise = p == Just (L.head s)-  where p = maybeP P.anyWord8 s--notWord8 w (NonEmpty s) = maybeP (P.notWord8 w) bs == if v == w-                                                      then Nothing-                                                      else Just v-    where v = L.head bs-          bs = L.pack s--string s t = maybeP (P.string s') (s `L.append` t) == Just s'-  where s' = toStrict s--toStrict = B.concat . L.toChunks--skipWhile w s =-    let t = L.dropWhile (<=w) s-    in case defP (P.skipWhile (<=w)) s of-         PL.Done t' () -> t == t'-         _             -> False--takeCount (Positive k) s =-    case maybeP (P.take k) s of-      Nothing -> fromIntegral k > L.length s-      Just s' -> fromIntegral k <= L.length s--takeWhile w s =-    let (h,t) = L.span (==w) s-    in case defP (P.takeWhile (==w)) s of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeWhile1 w s =-    let s'    = L.cons w s-        (h,t) = L.span (<=w) s'-    in case defP (P.takeWhile1 (<=w)) s' of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeTill w s =-    let (h,t) = L.break (==w) s-    in case defP (P.takeTill (==w)) s of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeWhile1_empty = maybeP (P.takeWhile1 undefined) L.empty == Nothing--endOfInput s = maybeP P.endOfInput s == if L.null s-                                        then Just ()-                                        else Nothing--tests = [-    testProperty "satisfy" satisfy,-    testProperty "word8" word8,-    testProperty "notWord8" notWord8,-    testProperty "anyWord8" anyWord8,-    testProperty "string" string,-    testProperty "skipWhile" skipWhile,-    testProperty "takeCount" takeCount,-    testProperty "takeWhile" takeWhile,-    testProperty "takeWhile1" takeWhile1,-    testProperty "takeWhile1_empty" takeWhile1_empty,-    testProperty "takeTill" takeTill,-    testProperty "endOfInput" endOfInput-  ]
− tests/QC/Text.hs
@@ -1,105 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-module QC.Text (tests) where--import Control.Applicative ((<$>))-import Prelude hiding (takeWhile)-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.QuickCheck-import qualified Data.Attoparsec.Text as P-import qualified Data.Attoparsec.Text.Lazy as PL-import qualified Data.Text as T-import qualified Data.Text.Lazy as L--instance Arbitrary T.Text where-    arbitrary   = T.pack <$> arbitrary--instance Arbitrary L.Text where-    arbitrary   = sized $ \n -> resize (round (sqrt (toEnum n :: Double)))-                  ((L.fromChunks . map (T.pack . nonEmpty)) <$> arbitrary)-      where nonEmpty (NonEmpty a) = a---- Naming.--{--label (NonEmpty s) = case parse (anyChar <?> s) T.empty of-                            (_, Left err) -> s `isInfixOf` err-                            _             -> False--}---- Basic byte-level combinators.--maybeP p = PL.maybeResult . PL.parse p--defP p = PL.parse p--satisfy w s = maybeP (P.satisfy (<=w)) (L.cons w s) == Just w--char w s = maybeP (P.char w) (L.cons w s) == Just w--anyChar s-    | L.null s  = p == Nothing-    | otherwise = p == Just (L.head s)-  where p = maybeP P.anyChar s--notChar w (NonEmpty s) = maybeP (P.notChar w) bs == if v == w-                                                      then Nothing-                                                      else Just v-    where v = L.head bs-          bs = L.pack s--string s t = maybeP (P.string s') (s `L.append` t) == Just s'-  where s' = toStrict s--toStrict = T.concat . L.toChunks--skipWhile w s =-    let t = L.dropWhile (<=w) s-    in case defP (P.skipWhile (<=w)) s of-         PL.Done t' () -> t == t'-         _             -> False--takeCount (Positive k) s =-    case maybeP (P.take k) s of-      Nothing -> fromIntegral k > L.length s-      Just s' -> fromIntegral k <= L.length s--takeWhile w s =-    let (h,t) = L.span (==w) s-    in case defP (P.takeWhile (==w)) s of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeWhile1 w s =-    let s'    = L.cons w s-        (h,t) = L.span (<=w) s'-    in case defP (P.takeWhile1 (<=w)) s' of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeTill w s =-    let (h,t) = L.break (==w) s-    in case defP (P.takeTill (==w)) s of-         PL.Done t' h' -> t == t' && toStrict h == h'-         _             -> False--takeWhile1_empty = maybeP (P.takeWhile1 undefined) L.empty == Nothing--endOfInput s = maybeP P.endOfInput s == if L.null s-                                        then Just ()-                                        else Nothing--tests = [-    testProperty "satisfy" satisfy,-    testProperty "char" char,-    testProperty "notChar" notChar,-    testProperty "anyChar" anyChar,-    testProperty "string" string,-    testProperty "skipWhile" skipWhile,-    testProperty "takeCount" takeCount,-    testProperty "takeWhile" takeWhile,-    testProperty "takeWhile1" takeWhile1,-    testProperty "takeWhile1_empty" takeWhile1_empty,-    testProperty "takeTill" takeTill,-    testProperty "endOfInput" endOfInput-  ]