Skip to content

Commit

Permalink
Use ‘parser-combinators-0.4.0’
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Dec 31, 2017
1 parent 5fb983f commit fce1d00
Show file tree
Hide file tree
Showing 10 changed files with 535 additions and 228 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,24 @@
## Megaparsec 6.4.0

* `Text.Megaparsec` now re-exports `Control.Monad.Combinators` instead of
`Control.Applicative.Combinators` from `parser-combinators` because the
monadic counterparts of the familiar combinators are more efficient and
not as leaky.

This may cause minor breakage in certain cases:

* You import `Control.Applicative` and in that case there will be a name
conflict between `Control.Applicative.many` and
`Control.Monad.Combinator.many` now (the same for `some`).

* You define a polymorphic helper in terms of combinator(s) from
`Control.Applicative.Combinators` and use `Applicative` or `Alternative`
constraint. In this case you'll have to adjust the constraint to be
`Monad` or `MonadPlus` respectively.

Also note that the new `Control.Monad.Combinators` module we re-export now
re-exports `empty` from `Control.Applicative`.

* Fix the `atEnd` parser. It now does not produce hints, so when you use it,
it won't contribute to the “expecting end of input” component of parse
error.
Expand Down
4 changes: 2 additions & 2 deletions Text/Megaparsec.hs
Expand Up @@ -77,7 +77,7 @@ module Text.Megaparsec
module Text.Megaparsec.Pos
, module Text.Megaparsec.Error
, module Text.Megaparsec.Stream
, module Control.Applicative.Combinators
, module Control.Monad.Combinators
-- * Data types
, State (..)
, Parsec
Expand Down Expand Up @@ -118,9 +118,9 @@ module Text.Megaparsec
, dbg )
where

import Control.Applicative.Combinators
import Control.DeepSeq
import Control.Monad
import Control.Monad.Combinators
import Control.Monad.Cont.Class
import Control.Monad.Error.Class
import Control.Monad.Identity
Expand Down
11 changes: 6 additions & 5 deletions Text/Megaparsec/Perm.hs
Expand Up @@ -29,7 +29,7 @@ where
import Text.Megaparsec

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>), (<*>))
import Control.Applicative
#endif

infixl 1 <||>, <|?>
Expand Down Expand Up @@ -61,10 +61,11 @@ data Branch s m a = forall b. Branch (PermParser s m (b -> a)) (m b)
makePermParser :: MonadParsec e s m
=> PermParser s m a -- ^ Given permutation parser
-> m a -- ^ Normal parser built from it
makePermParser (Perm def xs) = choice (fmap branch xs ++ empty)
where empty = case def of
Nothing -> []
Just x -> [return x]
makePermParser (Perm def xs) = choice (fmap branch xs ++ empty')
where empty' =
case def of
Nothing -> []
Just x -> [return x]
branch (Branch perm p) = flip ($) <$> p <*> makePermParser perm

-- | The expression @f \<$$> p@ creates a fresh permutation parser
Expand Down
3 changes: 2 additions & 1 deletion megaparsec.cabal
Expand Up @@ -40,7 +40,7 @@ library
, containers >= 0.5 && < 0.6
, deepseq >= 1.3 && < 1.5
, mtl >= 2.0 && < 3.0
, parser-combinators >= 0.1 && < 1.0
, parser-combinators >= 0.4 && < 1.0
, scientific >= 0.3.1 && < 0.4
, text >= 0.2 && < 1.3
, transformers >= 0.4 && < 0.6
Expand Down Expand Up @@ -75,6 +75,7 @@ test-suite tests
else
ghc-options: -O2 -Wall
other-modules: Control.Applicative.CombinatorsSpec
, Control.Monad.CombinatorsSpec
, Test.Hspec.Megaparsec
, Test.Hspec.Megaparsec.AdHoc
, Text.Megaparsec.Byte.LexerSpec
Expand Down
2 changes: 2 additions & 0 deletions stack.yaml
@@ -1,3 +1,5 @@
resolver: lts-10.0
packages:
- '.'
extra-deps:
- parser-combinators-0.4.0

0 comments on commit fce1d00

Please sign in to comment.