parsers 0.12.11 → 0.12.12
raw patch · 9 files changed
+36/−118 lines, 9 filesdep −base-orphansdep ~basedep ~containersdep ~textPVP ok
version bump matches the API change (PVP)
Dependencies removed: base-orphans
Dependency ranges changed: base, containers, text
API changes (from Hackage documentation)
Files
- CHANGELOG.markdown +5/−0
- parsers.cabal +11/−18
- src/Text/Parser/Char.hs +4/−16
- src/Text/Parser/Combinators.hs +4/−37
- src/Text/Parser/Expression.hs +1/−1
- src/Text/Parser/LookAhead.hs +1/−11
- src/Text/Parser/Token.hs +8/−13
- src/Text/Parser/Token/Style.hs +1/−7
- tests/QuickCheck.hs +1/−15
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.12.12 [2024.10.26]+--------------------+* Support building with `text-2.1.2`.+* Drop support for pre-8.0 versions of GHC.+ 0.12.11 [2022.05.07] -------------------- * Allow building with `transformers-0.6.*` and `mtl-2.3.*`.
parsers.cabal view
@@ -1,6 +1,6 @@ name: parsers category: Text, Parsing-version: 0.12.11+version: 0.12.12 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -18,20 +18,18 @@ get access to a large number of canned definitions. Instances exist for the parsers provided by @parsec@, @attoparsec@ and base’s "Text.Read". build-type: Simple-tested-with: GHC==7.0.4- , GHC==7.2.2- , GHC==7.4.2- , GHC==7.6.3- , GHC==7.8.4- , GHC==7.10.3- , GHC==8.0.2+tested-with: GHC==8.0.2 , GHC==8.2.2 , GHC==8.4.4 , GHC==8.6.5 , GHC==8.8.4 , GHC==8.10.7 , GHC==9.0.2- , GHC==9.2.2+ , GHC==9.2.8+ , GHC==9.4.8+ , GHC==9.6.6+ , GHC==9.8.2+ , GHC==9.10.1 extra-source-files: .hlint.yaml@@ -71,18 +69,13 @@ hs-source-dirs: src - ghc-options: -Wall -fno-warn-wrong-do-bind -fwarn-monomorphism-restriction -fwarn-incomplete-record-updates- if impl(ghc >= 7.2)- ghc-options: -fwarn-identities -fwarn-incomplete-uni-patterns- if impl(ghc >= 7.10)- ghc-options: -fno-warn-trustworthy-safe+ ghc-options: -Wall -Wno-wrong-do-bind -Wmonomorphism-restriction -Wincomplete-record-updates -Widentities -Wincomplete-uni-patterns -Wno-trustworthy-safe build-depends:- base >= 4.3 && < 5,- base-orphans >= 0.3 && < 1,+ base >= 4.9 && < 5, charset >= 0.3 && < 1,- containers >= 0.4 && < 0.7,- text >= 0.10 && < 2.1,+ containers >= 0.4 && < 0.8,+ text >= 0.10 && < 2.2, transformers >= 0.2 && < 0.7, mtl >= 2.0.1 && < 2.4, scientific >= 0.3 && < 0.4,
src/Text/Parser/Char.hs view
@@ -1,15 +1,10 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fspec-constr -fspec-constr-count=8 #-}--#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704-#define USE_DEFAULT_SIGNATURES-#endif--#ifdef USE_DEFAULT_SIGNATURES-{-# LANGUAGE DefaultSignatures, TypeFamilies, TypeOperators #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Text.Parser.Char@@ -46,9 +41,6 @@ , CharParsing(..) ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Monad.Trans.Class import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict@@ -64,9 +56,6 @@ import qualified Data.CharSet as CharSet import Data.Foldable import qualified Data.IntSet as IntSet-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid-#endif import qualified Data.Text as Text import Data.Text (Text) import qualified Text.ParserCombinators.ReadP as ReadP@@ -187,12 +176,11 @@ class Parsing m => CharParsing m where -- | Parse a single character of the input, with UTF-8 decoding satisfy :: (Char -> Bool) -> m Char-#ifdef USE_DEFAULT_SIGNATURES default satisfy :: (MonadTrans t, CharParsing n, Monad n, m ~ t n) => (Char -> Bool) -> m Char satisfy = lift . satisfy-#endif+ -- | @char c@ parses a single character @c@. Returns the parsed -- character (i.e. @c@). --
src/Text/Parser/Combinators.hs view
@@ -1,22 +1,9 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704-#define USE_DEFAULT_SIGNATURES-#endif--#ifdef USE_DEFAULT_SIGNATURES-{-# LANGUAGE DefaultSignatures, TypeFamilies, TypeOperators #-}-#endif--#if !MIN_VERSION_base(4,6,0)-#define ORPHAN_ALTERNATIVE_READP-#endif--#ifdef ORPHAN_ALTERNATIVE_READP-{-# OPTIONS_GHC -fno-warn-orphans #-}-#endif- ----------------------------------------------------------------------------- -- | -- Module : Text.Parser.Combinators@@ -61,7 +48,7 @@ ) where import Control.Applicative-import Control.Monad (MonadPlus(..), void)+import Control.Monad (MonadPlus(..), replicateM, void) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict@@ -74,13 +61,6 @@ import qualified Data.Foldable as F import qualified Data.List.NonEmpty as NonEmpty import Data.List.NonEmpty (NonEmpty(..))-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid-#ifdef ORPHAN_ALTERNATIVE_READP-import Data.Orphans ()-#endif-import Data.Traversable (sequenceA)-#endif #ifdef MIN_VERSION_parsec import qualified Text.Parsec as Parsec@@ -98,10 +78,6 @@ import qualified Data.Binary.Get as B #endif -#if MIN_VERSION_base(4,9,0)-import Control.Monad (replicateM)-#endif- -- | @choice ps@ tries to apply the parsers in the list @ps@ in order, -- until one of them succeeds. Returns the value of the succeeding -- parser.@@ -204,12 +180,7 @@ -- equal to zero, the parser equals to @return []@. Returns a list of -- @n@ values returned by @p@. count :: Applicative m => Int -> m a -> m [a]-#if MIN_VERSION_base(4,9,0) count = replicateM-#else-count n p | n <= 0 = pure []- | otherwise = sequenceA (replicate n p)-#endif {-# INLINE count #-} -- | @chainr p op x@ parses /zero/ or more occurrences of @p@,@@ -300,23 +271,19 @@ -- | Used to emit an error on an unexpected token unexpected :: String -> m a-#ifdef USE_DEFAULT_SIGNATURES default unexpected :: (MonadTrans t, Monad n, Parsing n, m ~ t n) => String -> m a unexpected = lift . unexpected {-# INLINE unexpected #-}-#endif -- | This parser only succeeds at the end of the input. This is not a -- primitive parser but it is defined using 'notFollowedBy'. -- -- > eof = notFollowedBy anyChar <?> "end of input" eof :: m ()-#ifdef USE_DEFAULT_SIGNATURES default eof :: (MonadTrans t, Monad n, Parsing n, m ~ t n) => m () eof = lift eof {-# INLINE eof #-}-#endif -- | @notFollowedBy p@ only succeeds when parser @p@ fails. This parser -- does not consume any input. This parser can be used to implement the
src/Text/Parser/Expression.hs view
@@ -38,7 +38,7 @@ = AssocNone | AssocLeft | AssocRight- deriving (Eq,Ord,Show,Read,Ix,Enum,Bounded,Data,Typeable)+ deriving (Eq,Ord,Show,Read,Ix,Enum,Bounded,Data) -- | This data type specifies operators that work on values of type @a@. -- An operator is either binary infix or unary prefix or postfix. A
src/Text/Parser/LookAhead.hs view
@@ -1,13 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE UndecidableInstances #-}--#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704-#define USE_DEFAULT_SIGNATURES-#endif--#ifdef USE_DEFAULT_SIGNATURES-{-# LANGUAGE DefaultSignatures, TypeFamilies #-}-#endif+{-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- |@@ -36,9 +29,6 @@ import Control.Monad.Trans.RWS.Strict as Strict import Control.Monad.Trans.Reader import Control.Monad.Trans.Identity-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid-#endif import qualified Text.ParserCombinators.ReadP as ReadP import Text.Parser.Combinators
src/Text/Parser/Token.hs view
@@ -4,11 +4,9 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE UndecidableInstances #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}-#endif+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} {-# OPTIONS_GHC -fspec-constr -fspec-constr-count=8 #-} ----------------------------------------------------------------------------- -- |@@ -104,14 +102,11 @@ import Data.Functor.Identity import qualified Data.HashSet as HashSet import Data.HashSet (HashSet)-import Data.List (foldl', transpose)-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid-#endif+import qualified Data.List as List (foldl', transpose) import Data.Scientific ( Scientific ) import qualified Data.Scientific as Sci import Data.String-import Data.Text hiding (empty,zip,foldl',take,map,length,splitAt,null,transpose)+import Data.Text (Text) import Numeric (showIntAtBase) import qualified Text.ParserCombinators.ReadP as ReadP import Text.Parser.Char@@ -627,11 +622,11 @@ maxchar = fromEnum (maxBound :: Char) bounded :: Int -> Int -> m Int- bounded base bnd = foldl' (\x d -> base * x + digitToInt d) 0+ bounded base bnd = List.foldl' (\x d -> base * x + digitToInt d) 0 <$> bounded' (take base thedigits) (map digitToInt $ showIntAtBase base intToDigit bnd "") where thedigits :: [m Char]- thedigits = map char ['0'..'9'] ++ map oneOf (transpose [['A'..'F'],['a'..'f']])+ thedigits = map char ['0'..'9'] ++ map oneOf (List.transpose [['A'..'F'],['a'..'f']]) toomuch :: m a toomuch = unexpected "out-of-range numeric escape sequence"@@ -688,7 +683,7 @@ number :: TokenParsing m => Integer -> m Char -> m Integer number base baseDigit =- foldl' (\x d -> base*x + toInteger (digitToInt d)) 0 <$> some baseDigit+ List.foldl' (\x d -> base*x + toInteger (digitToInt d)) 0 <$> some baseDigit -- | This parser parses an integer (a whole number). This parser -- is like 'natural' except that it can be prefixed with@@ -727,7 +722,7 @@ <|> (\expo n -> fromInteger n * expo) <$> exponent' where fraction :: m Scientific- fraction = foldl' op 0 <$> (char '.' *> (some digit <?> "fraction"))+ fraction = List.foldl' op 0 <$> (char '.' *> (some digit <?> "fraction")) op f d = f + Sci.scientific (fromIntegral (digitToInt d)) (Sci.base10Exponent f - 1)
src/Text/Parser/Token/Style.hs view
@@ -1,9 +1,6 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE ScopedTypeVariables #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Text.Parser.Token.Style@@ -44,9 +41,6 @@ import Control.Monad (void) import qualified Data.HashSet as HashSet import Data.HashSet (HashSet)-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid-#endif import Data.Data import Text.Parser.Combinators import Text.Parser.Char@@ -60,7 +54,7 @@ , _commentEnd :: String -- ^ String that ends a multiline comment , _commentLine :: String -- ^ String that starts a single line comment , _commentNesting :: Bool -- ^ Can we nest multiline comments?- } deriving (Eq,Ord,Show,Read,Data,Typeable)+ } deriving (Eq,Ord,Show,Read,Data) -- | This is a lens that can edit the string that starts a multiline comment. --
tests/QuickCheck.hs view
@@ -12,11 +12,8 @@ #ifdef MIN_VERSION_attoparsec import Data.Attoparsec.Text (parseOnly) #endif-import Data.String--#if MIN_VERSION_base(4,7,0) import Data.Either-#endif+import Data.String import Test.QuickCheck import Test.QuickCheck.Instances ()@@ -108,14 +105,3 @@ prop_notFollowedBy3 :: TestParser () -> Char -> Bool prop_notFollowedBy3 (TestParser _ p) x = isRight $ p (P (notFollowedBy (char x) <|> char x *> pure ())) [x]---- -------------------------------------------------------------------------- ----- Utils--#if !MIN_VERSION_base(4,7,0)-isLeft :: Either a b -> Bool-isLeft = either (const True) (const False)--isRight :: Either a b -> Bool-isRight = either (const False) (const True)-#endif