summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenGamari <>2018-01-12 19:52:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-01-12 19:52:00 (GMT)
commit5400adb2cccd0282d4c0e74deaa1ae296779fe0a (patch)
treef4d106cfb7e9759f1d2f3c73dcc3845ee33363a1
parent3128ecff80e2ddac045c71b6c1f0dae73c340433 (diff)
version 0.13.2.10.13.2.1
-rw-r--r--Data/Attoparsec/Text/Internal.hs17
-rw-r--r--attoparsec.cabal2
-rw-r--r--changelog.md4
3 files changed, 14 insertions, 9 deletions
diff --git a/Data/Attoparsec/Text/Internal.hs b/Data/Attoparsec/Text/Internal.hs
index 185bc20..2391fbb 100644
--- a/Data/Attoparsec/Text/Internal.hs
+++ b/Data/Attoparsec/Text/Internal.hs
@@ -75,7 +75,7 @@ import Data.Attoparsec.Internal
import Data.Attoparsec.Internal.Types hiding (Parser, Failure, Success)
import qualified Data.Attoparsec.Text.Buffer as Buf
import Data.Attoparsec.Text.Buffer (Buffer, buffer)
-import Data.Char (chr, ord)
+import Data.Char (isAsciiUpper, isAsciiLower, toUpper, toLower)
import Data.List (intercalate)
import Data.String (IsString(..))
import Data.Text.Internal (Text(..))
@@ -225,15 +225,16 @@ stringCI s = go 0
-- | Satisfy a literal string, ignoring case for characters in the ASCII range.
asciiCI :: Text -> Parser Text
-asciiCI s = string_ (stringSuspended asciiToLower) asciiToLower s
- where
- asciiToLower = T.map f
- where
- offset = ord 'a' - ord 'A'
- f c | 'A' <= c && c <= 'Z' = chr (ord c + offset)
- | otherwise = c
+asciiCI s = fmap fst $ match $ T.foldr ((*>) . asciiCharCI) (pure ()) s
{-# INLINE asciiCI #-}
+asciiCharCI :: Char -> Parser Char
+asciiCharCI c
+ | isAsciiUpper c = char c <|> char (toLower c)
+ | isAsciiLower c = char c <|> char (toUpper c)
+ | otherwise = char c
+{-# INLINE asciiCharCI #-}
+
-- | Skip past input for as long as the predicate returns 'True'.
skipWhile :: (Char -> Bool) -> Parser ()
skipWhile p = go
diff --git a/attoparsec.cabal b/attoparsec.cabal
index 4eef160..dd34560 100644
--- a/attoparsec.cabal
+++ b/attoparsec.cabal
@@ -1,5 +1,5 @@
name: attoparsec
-version: 0.13.2.0
+version: 0.13.2.1
license: BSD3
license-file: LICENSE
category: Text, Parsing
diff --git a/changelog.md b/changelog.md
index 140785e..82e56fb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,7 @@
+0.13.2.0
+
+* `pure` is now strict in `Position`
+
0.13.1.0
* `runScanner` now correctly returns the final state