mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-11-24 03:52:07 +03:00
Merge pull request #50 from bkaestner/base-4600
Add base-4.6.0.x compatiblity
This commit is contained in:
commit
9e445f844b
@ -28,7 +28,9 @@ module Text.Megaparsec.Error
|
||||
, showMessages )
|
||||
where
|
||||
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.List (intercalate)
|
||||
import Data.Maybe (fromMaybe)
|
||||
|
||||
@ -38,6 +40,11 @@ import Text.Megaparsec.Pos
|
||||
import Control.Applicative ((<$>))
|
||||
import Data.Foldable (foldMap)
|
||||
#endif
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
-- | This data type represents parse error messages. There are three kinds
|
||||
-- of messages:
|
||||
|
@ -40,7 +40,9 @@ module Text.Megaparsec.Prim
|
||||
, parseTest )
|
||||
where
|
||||
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.Monoid
|
||||
|
||||
import Control.Monad
|
||||
@ -70,6 +72,11 @@ import Text.Megaparsec.ShowToken
|
||||
#if !MIN_VERSION_base(4,8,0)
|
||||
import Control.Applicative ((<$>), (<*))
|
||||
#endif
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
-- | This is Megaparsec state, it's parametrized over stream type @s@.
|
||||
|
||||
|
@ -76,7 +76,7 @@ description:
|
||||
extra-source-files: AUTHORS.md, CHANGELOG.md
|
||||
|
||||
library
|
||||
build-depends: base >= 4.7 && < 5
|
||||
build-depends: base >= 4.6 && < 5
|
||||
, mtl == 2.*
|
||||
, transformers == 0.4.*
|
||||
, bytestring
|
||||
@ -122,7 +122,7 @@ test-suite old-tests
|
||||
, Bugs.Bug35
|
||||
, Bugs.Bug39
|
||||
, Util
|
||||
build-depends: base >= 4.7 && < 5
|
||||
build-depends: base >= 4.6 && < 5
|
||||
, megaparsec >= 4.0.0
|
||||
, HUnit >= 1.2 && < 1.4
|
||||
, test-framework >= 0.6 && < 1
|
||||
@ -146,7 +146,7 @@ test-suite tests
|
||||
, Pos
|
||||
, Prim
|
||||
, Util
|
||||
build-depends: base >= 4.7 && < 5
|
||||
build-depends: base >= 4.6 && < 5
|
||||
, megaparsec >= 4.0.0
|
||||
, mtl == 2.*
|
||||
, transformers == 0.4.*
|
||||
@ -164,7 +164,7 @@ benchmark benchmarks
|
||||
hs-source-dirs: benchmarks
|
||||
type: exitcode-stdio-1.0
|
||||
ghc-options: -O2 -Wall -rtsopts
|
||||
build-depends: base >= 4.7 && < 5
|
||||
build-depends: base >= 4.6 && < 5
|
||||
, megaparsec >= 4.0.0
|
||||
, criterion >= 0.6.2.1 && < 1.2
|
||||
, text >= 1.2 && < 2
|
||||
|
@ -3,7 +3,9 @@ module Bugs.Bug39 (main) where
|
||||
|
||||
import Control.Applicative (empty)
|
||||
import Control.Monad (void)
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Either (isLeft, isRight)
|
||||
#endif
|
||||
|
||||
import Text.Megaparsec
|
||||
import Text.Megaparsec.String
|
||||
@ -13,6 +15,14 @@ import Test.Framework
|
||||
import Test.Framework.Providers.HUnit
|
||||
import Test.HUnit hiding (Test)
|
||||
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
isRight, isLeft :: Either a b -> Bool
|
||||
isRight (Right _) = True
|
||||
isRight _ = False
|
||||
isLeft (Left _ ) = True
|
||||
isLeft _ = False
|
||||
#endif
|
||||
|
||||
shouldFail :: [String]
|
||||
shouldFail = [" 1", " +1", " -1"]
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
module Error (tests) where
|
||||
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.List (isPrefixOf, isInfixOf)
|
||||
|
||||
import Test.Framework
|
||||
@ -45,6 +47,11 @@ import Text.Megaparsec.Pos
|
||||
#if !MIN_VERSION_base(4,8,0)
|
||||
import Control.Applicative ((<$>), (<*>))
|
||||
#endif
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
tests :: Test
|
||||
tests = testGroup "Parse errors"
|
||||
|
@ -30,7 +30,9 @@
|
||||
module Expr (tests) where
|
||||
|
||||
import Control.Applicative (some, (<|>))
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
|
||||
import Test.Framework
|
||||
import Test.Framework.Providers.QuickCheck2 (testProperty)
|
||||
@ -47,6 +49,12 @@ import Util
|
||||
import Control.Applicative ((<$>), (<*), (<*>), (*>), pure)
|
||||
#endif
|
||||
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
tests :: Test
|
||||
tests = testGroup "Expression parsers"
|
||||
[ testProperty "correctness of expression parser" prop_correctness ]
|
||||
|
@ -31,7 +31,9 @@ module Lexer (tests) where
|
||||
|
||||
import Control.Applicative (empty)
|
||||
import Control.Monad (void)
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.Char
|
||||
( readLitChar
|
||||
, showLitChar
|
||||
@ -59,6 +61,11 @@ import Util
|
||||
#if !MIN_VERSION_base(4,8,0)
|
||||
import Control.Applicative ((<$>), (<*), (<*>))
|
||||
#endif
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
tests :: Test
|
||||
tests = testGroup "Lexer"
|
||||
|
@ -30,7 +30,9 @@
|
||||
module Perm (tests) where
|
||||
|
||||
import Control.Applicative
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.List (nub, elemIndices)
|
||||
|
||||
import Test.Framework
|
||||
@ -41,6 +43,11 @@ import Text.Megaparsec.Char
|
||||
import Text.Megaparsec.Perm
|
||||
|
||||
import Util
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
tests :: Test
|
||||
tests = testGroup "Permutation phrases parsers"
|
||||
|
@ -32,7 +32,9 @@
|
||||
module Prim (tests) where
|
||||
|
||||
import Control.Applicative
|
||||
#if MIN_VERSION_base(4,7,0)
|
||||
import Data.Bool (bool)
|
||||
#endif
|
||||
import Data.Char (isLetter, toUpper)
|
||||
import Data.Foldable (asum)
|
||||
import Data.List (isPrefixOf)
|
||||
@ -57,6 +59,11 @@ import Text.Megaparsec.String
|
||||
|
||||
import Pos ()
|
||||
import Util
|
||||
#if !MIN_VERSION_base(4,7,0)
|
||||
bool :: a -> a -> Bool -> a
|
||||
bool f _ False = f
|
||||
bool _ t True = t
|
||||
#endif
|
||||
|
||||
tests :: Test
|
||||
tests = testGroup "Primitive parser combinators"
|
||||
|
Loading…
Reference in New Issue
Block a user