parser-combinators 1.3.0 → 1.3.1
raw patch · 11 files changed
+89/−92 lines, 11 filesdep ~basesetup-changed
Dependency ranges changed: base
Files
- CHANGELOG.md +4/−0
- Control/Applicative/Combinators.hs +24/−22
- Control/Applicative/Combinators/NonEmpty.hs +5/−5
- Control/Applicative/Permutations.hs +11/−11
- Control/Monad/Combinators.hs +19/−19
- Control/Monad/Combinators/Expr.hs +7/−7
- Control/Monad/Combinators/NonEmpty.hs +5/−5
- Control/Monad/Permutations.hs +5/−5
- README.md +1/−1
- Setup.hs +0/−6
- parser-combinators.cabal +8/−11
CHANGELOG.md view
@@ -1,3 +1,7 @@+## Parser combinators 1.3.1++* Compiles with [MicroHs](https://github.com/augustss/MicroHs).+ ## Parser combinators 1.3.0 * Changed the `Control.Applicative.Permutations` module to only require
Control/Applicative/Combinators.hs view
@@ -82,9 +82,11 @@ ) where -import Control.Applicative+-- MicroHs has @Control.Applicative.asum :: Alternative f => [f a] -> f a@+-- so we use @Data.Foldable.asum@+import Control.Applicative hiding (asum) import Control.Monad (replicateM, replicateM_)-import Data.Foldable+import Data.Foldable (asum) ---------------------------------------------------------------------------- -- Re-exports from "Control.Applicative"@@ -132,7 +134,7 @@ -- Returns the value returned by @p@. -- -- > braces = between (symbol "{") (symbol "}")-between :: Applicative m => m open -> m close -> m a -> m a+between :: (Applicative m) => m open -> m close -> m a -> m a between open close p = open *> p <* close {-# INLINE between #-} @@ -151,7 +153,7 @@ -- > count = replicateM -- -- See also: 'skipCount', 'count''.-count :: Applicative m => Int -> m a -> m [a]+count :: (Applicative m) => Int -> m a -> m [a] count = replicateM {-# INLINE count #-} @@ -163,7 +165,7 @@ -- as if it were equal to zero. -- -- See also: 'skipCount', 'count'.-count' :: Alternative m => Int -> Int -> m a -> m [a]+count' :: (Alternative m) => Int -> Int -> m a -> m [a] count' m' n' p = go m' n' where go !m !n@@ -175,7 +177,7 @@ -- | Combine two alternatives. -- -- > eitherP a b = (Left <$> a) <|> (Right <$> b)-eitherP :: Alternative m => m a -> m b -> m (Either a b)+eitherP :: (Alternative m) => m a -> m b -> m (Either a b) eitherP a b = (Left <$> a) <|> (Right <$> b) {-# INLINE eitherP #-} @@ -183,13 +185,13 @@ -- ended by @sep@. Returns a list of values returned by @p@. -- -- > cStatements = cStatement `endBy` semicolon-endBy :: Alternative m => m a -> m sep -> m [a]+endBy :: (Alternative m) => m a -> m sep -> m [a] endBy p sep = many (p <* sep) {-# INLINE endBy #-} -- | @'endBy1' p sep@ parses /one/ or more occurrences of @p@, separated and -- ended by @sep@. Returns a list of values returned by @p@.-endBy1 :: Alternative m => m a -> m sep -> m [a]+endBy1 :: (Alternative m) => m a -> m sep -> m [a] endBy1 p sep = some (p <* sep) {-# INLINE endBy1 #-} @@ -198,7 +200,7 @@ -- is consumed and lost. Use 'manyTill_' if you wish to keep it. -- -- See also: 'skipMany', 'skipManyTill'.-manyTill :: Alternative m => m a -> m end -> m [a]+manyTill :: (Alternative m) => m a -> m end -> m [a] manyTill p end = go where go = ([] <$ end) <|> liftA2 (:) p go@@ -212,7 +214,7 @@ -- See also: 'skipMany', 'skipManyTill'. -- -- @since 1.2.0-manyTill_ :: Alternative m => m a -> m end -> m ([a], end)+manyTill_ :: (Alternative m) => m a -> m end -> m ([a], end) manyTill_ p end = go where go = (([],) <$> end) <|> liftA2 (\x (xs, y) -> (x : xs, y)) p go@@ -225,7 +227,7 @@ -- > someTill p end = liftA2 (:) p (manyTill p end) -- -- See also: 'skipSome', 'skipSomeTill'.-someTill :: Alternative m => m a -> m end -> m [a]+someTill :: (Alternative m) => m a -> m end -> m [a] someTill p end = liftA2 (:) p (manyTill p end) {-# INLINE someTill #-} @@ -236,7 +238,7 @@ -- See also: 'skipSome', 'skipSomeTill'. -- -- @since 1.2.0-someTill_ :: Alternative m => m a -> m end -> m ([a], end)+someTill_ :: (Alternative m) => m a -> m end -> m ([a], end) someTill_ p end = liftA2 (\x (xs, y) -> (x : xs, y)) p (manyTill_ p end) {-# INLINE someTill_ #-}@@ -248,7 +250,7 @@ -- > option x p = p <|> pure x -- -- See also: 'optional'.-option :: Alternative m => a -> m a -> m a+option :: (Alternative m) => a -> m a -> m a option x p = p <|> pure x {-# INLINE option #-} @@ -256,25 +258,25 @@ -- @sep@. Returns a list of values returned by @p@. -- -- > commaSep p = p `sepBy` comma-sepBy :: Alternative m => m a -> m sep -> m [a]+sepBy :: (Alternative m) => m a -> m sep -> m [a] sepBy p sep = sepBy1 p sep <|> pure [] {-# INLINE sepBy #-} -- | @'sepBy1' p sep@ parses /one/ or more occurrences of @p@, separated by -- @sep@. Returns a list of values returned by @p@.-sepBy1 :: Alternative m => m a -> m sep -> m [a]+sepBy1 :: (Alternative m) => m a -> m sep -> m [a] sepBy1 p sep = liftA2 (:) p (many (sep *> p)) {-# INLINE sepBy1 #-} -- | @'sepEndBy' p sep@ parses /zero/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a list of values returned by @p@.-sepEndBy :: Alternative m => m a -> m sep -> m [a]+sepEndBy :: (Alternative m) => m a -> m sep -> m [a] sepEndBy p sep = sepEndBy1 p sep <|> pure [] {-# INLINE sepEndBy #-} -- | @'sepEndBy1' p sep@ parses /one/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a list of values returned by @p@.-sepEndBy1 :: Alternative m => m a -> m sep -> m [a]+sepEndBy1 :: (Alternative m) => m a -> m sep -> m [a] sepEndBy1 p sep = liftA2 (:) p ((sep *> sepEndBy p sep) <|> pure []) {-# INLINEABLE sepEndBy1 #-} @@ -282,7 +284,7 @@ -- its result. -- -- See also: 'manyTill', 'skipManyTill'.-skipMany :: Alternative m => m a -> m ()+skipMany :: (Alternative m) => m a -> m () skipMany p = go where go = (p *> go) <|> pure ()@@ -292,7 +294,7 @@ -- result. -- -- See also: 'someTill', 'skipSomeTill'.-skipSome :: Alternative m => m a -> m ()+skipSome :: (Alternative m) => m a -> m () skipSome p = p *> skipMany p {-# INLINE skipSome #-} @@ -304,7 +306,7 @@ -- See also: 'count', 'count''. -- -- @since 0.3.0-skipCount :: Applicative m => Int -> m a -> m ()+skipCount :: (Applicative m) => Int -> m a -> m () skipCount = replicateM_ {-# INLINE skipCount #-} @@ -313,7 +315,7 @@ -- then returned. -- -- See also: 'manyTill', 'skipMany'.-skipManyTill :: Alternative m => m a -> m end -> m end+skipManyTill :: (Alternative m) => m a -> m end -> m end skipManyTill p end = go where go = end <|> (p *> go)@@ -324,6 +326,6 @@ -- then returned. -- -- See also: 'someTill', 'skipSome'.-skipSomeTill :: Alternative m => m a -> m end -> m end+skipSomeTill :: (Alternative m) => m a -> m end -> m end skipSomeTill p end = p *> skipManyTill p end {-# INLINE skipSomeTill #-}
Control/Applicative/Combinators/NonEmpty.hs view
@@ -29,13 +29,13 @@ -- list of the values returned by @p@. -- -- > word = some letter-some :: Alternative m => m a -> m (NonEmpty a)+some :: (Alternative m) => m a -> m (NonEmpty a) some p = NE.fromList <$> C.some p {-# INLINE some #-} -- | @'endBy1' p sep@ parses /one/ or more occurrences of @p@, separated and -- ended by @sep@. Returns a non-empty list of values returned by @p@.-endBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)+endBy1 :: (Alternative m) => m a -> m sep -> m (NonEmpty a) endBy1 p sep = NE.fromList <$> C.endBy1 p sep {-# INLINE endBy1 #-} @@ -43,19 +43,19 @@ -- should succeed at least once. -- -- See also: 'C.skipSome', 'C.skipSomeTill'.-someTill :: Alternative m => m a -> m end -> m (NonEmpty a)+someTill :: (Alternative m) => m a -> m end -> m (NonEmpty a) someTill p end = NE.fromList <$> C.someTill p end {-# INLINE someTill #-} -- | @'sepBy1' p sep@ parses /one/ or more occurrences of @p@, separated by -- @sep@. Returns a non-empty list of values returned by @p@.-sepBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)+sepBy1 :: (Alternative m) => m a -> m sep -> m (NonEmpty a) sepBy1 p sep = NE.fromList <$> C.sepBy1 p sep {-# INLINE sepBy1 #-} -- | @'sepEndBy1' p sep@ parses /one/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a non-empty list of values returned by -- @p@.-sepEndBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)+sepEndBy1 :: (Alternative m) => m a -> m sep -> m (NonEmpty a) sepEndBy1 p sep = NE.fromList <$> C.sepEndBy1 p sep {-# INLINE sepEndBy1 #-}
Control/Applicative/Permutations.hs view
@@ -63,13 +63,13 @@ data Branch m a = forall z. Branch (Permutation m (z -> a)) (m z) -instance Functor m => Functor (Permutation m) where+instance (Functor m) => Functor (Permutation m) where fmap f (P v bs) = P (f <$> v) (fmap f <$> bs) -instance Functor p => Functor (Branch p) where+instance (Functor p) => Functor (Branch p) where fmap f (Branch perm p) = Branch (fmap (f .) perm) p -instance Functor m => Applicative (Permutation m) where+instance (Functor m) => Applicative (Permutation m) where pure value = P (Just value) empty lhs@(P f v) <*> rhs@(P g w) = P (f <*> g) $ (ins2 <$> v) <> (ins1 <$> w) where@@ -82,7 +82,7 @@ -- | \"Unlifts\" a permutation parser into a parser to be evaluated. runPermutation ::- Alternative m =>+ (Alternative m) => -- | Permutation specification Permutation m a -> -- | Resulting base monad capable of handling the permutation@@ -121,7 +121,7 @@ -- * If an effect is encountered after a component, another component must -- immediately follow the effect. intercalateEffect ::- Alternative m =>+ (Alternative m) => -- | Effect to be intercalated between permutation components m b -> -- | Permutation specification@@ -130,16 +130,16 @@ m a intercalateEffect effect = foldAlt (runBranchEff effect) where- runPermEff :: Alternative m => m b -> Permutation m a -> m a+ runPermEff :: (Alternative m) => m b -> Permutation m a -> m a runPermEff eff (P v bs) = eff *> foldr ((<|>) . runBranchEff eff) empty bs <|> maybe empty pure v - runBranchEff :: Alternative m => m b -> Branch m a -> m a+ runBranchEff :: (Alternative m) => m b -> Branch m a -> m a runBranchEff eff (Branch t p) = (&) <$> p <*> runPermEff eff t -- | \"Lifts\" a parser to a permutation parser. toPermutation ::- Alternative m =>+ (Alternative m) => -- | Permutation component m a -> Permutation m a@@ -150,7 +150,7 @@ -- If no permutation containing the supplied parser can be parsed from the input, -- then the supplied default value is returned in lieu of a parse result. toPermutationWithDefault ::- Alternative m =>+ (Alternative m) => -- | Default Value a -> -- | Permutation component@@ -158,8 +158,8 @@ Permutation m a toPermutationWithDefault v = P (Just v) . pure . branch -branch :: Functor m => m a -> Branch m a+branch :: (Functor m) => m a -> Branch m a branch = Branch $ pure id -foldAlt :: Alternative m => (Branch m a -> m a) -> Permutation m a -> m a+foldAlt :: (Alternative m) => (Branch m a -> m a) -> Permutation m a -> m a foldAlt f (P v bs) = foldr ((<|>) . f) (maybe empty pure v) bs
Control/Monad/Combinators.hs view
@@ -87,7 +87,7 @@ -- values. -- -- See also: 'skipCount', 'count''.-count :: Monad m => Int -> m a -> m [a]+count :: (Monad m) => Int -> m a -> m [a] count n' p = go id n' where go f !n =@@ -106,7 +106,7 @@ -- as if it were equal to zero. -- -- See also: 'skipCount', 'count'.-count' :: MonadPlus m => Int -> Int -> m a -> m [a]+count' :: (MonadPlus m) => Int -> Int -> m a -> m [a] count' m' n' p = if n' > 0 && n' >= m' then gom id m'@@ -132,13 +132,13 @@ -- ended by @sep@. Returns a list of values returned by @p@. -- -- > cStatements = cStatement `endBy` semicolon-endBy :: MonadPlus m => m a -> m sep -> m [a]+endBy :: (MonadPlus m) => m a -> m sep -> m [a] endBy p sep = many (p >>= \x -> x <$ sep) {-# INLINE endBy #-} -- | @'endBy1' p sep@ parses /one/ or more occurrences of @p@, separated and -- ended by @sep@. Returns a list of values returned by @p@.-endBy1 :: MonadPlus m => m a -> m sep -> m [a]+endBy1 :: (MonadPlus m) => m a -> m sep -> m [a] endBy1 p sep = some (p >>= \x -> x <$ sep) {-# INLINE endBy1 #-} @@ -146,7 +146,7 @@ -- list of the values returned by @p@. -- -- > identifier = (:) <$> letter <*> many (alphaNumChar <|> char '_')-many :: MonadPlus m => m a -> m [a]+many :: (MonadPlus m) => m a -> m [a] many p = go id where go f = do@@ -162,7 +162,7 @@ -- it. -- -- See also: 'skipMany', 'skipManyTill'.-manyTill :: MonadPlus m => m a -> m end -> m [a]+manyTill :: (MonadPlus m) => m a -> m end -> m [a] manyTill p end = fst <$> manyTill_ p end {-# INLINE manyTill #-} @@ -174,7 +174,7 @@ -- See also: 'skipMany', 'skipManyTill'. -- -- @since 1.2.0-manyTill_ :: MonadPlus m => m a -> m end -> m ([a], end)+manyTill_ :: (MonadPlus m) => m a -> m end -> m ([a], end) manyTill_ p end = go id where go f = do@@ -190,7 +190,7 @@ -- list of the values returned by @p@. -- -- > word = some letter-some :: MonadPlus m => m a -> m [a]+some :: (MonadPlus m) => m a -> m [a] some p = liftM2 (:) p (many p) {-# INLINE some #-} @@ -201,7 +201,7 @@ -- > someTill p end = liftM2 (:) p (manyTill p end) -- -- See also: 'skipSome', 'skipSomeTill'.-someTill :: MonadPlus m => m a -> m end -> m [a]+someTill :: (MonadPlus m) => m a -> m end -> m [a] someTill p end = liftM2 (:) p (manyTill p end) {-# INLINE someTill #-} @@ -212,7 +212,7 @@ -- See also: 'skipSome', 'skipSomeTill'. -- -- @since 1.2.0-someTill_ :: MonadPlus m => m a -> m end -> m ([a], end)+someTill_ :: (MonadPlus m) => m a -> m end -> m ([a], end) someTill_ p end = liftM2 (\x (xs, y) -> (x : xs, y)) p (manyTill_ p end) {-# INLINE someTill_ #-} @@ -220,7 +220,7 @@ -- @sep@. Returns a list of values returned by @p@. -- -- > commaSep p = p `sepBy` comma-sepBy :: MonadPlus m => m a -> m sep -> m [a]+sepBy :: (MonadPlus m) => m a -> m sep -> m [a] sepBy p sep = do r <- C.optional p case r of@@ -230,7 +230,7 @@ -- | @'sepBy1' p sep@ parses /one/ or more occurrences of @p@, separated by -- @sep@. Returns a list of values returned by @p@.-sepBy1 :: MonadPlus m => m a -> m sep -> m [a]+sepBy1 :: (MonadPlus m) => m a -> m sep -> m [a] sepBy1 p sep = do x <- p (x :) <$> many (sep >> p)@@ -238,7 +238,7 @@ -- | @'sepEndBy' p sep@ parses /zero/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a list of values returned by @p@.-sepEndBy :: MonadPlus m => m a -> m sep -> m [a]+sepEndBy :: (MonadPlus m) => m a -> m sep -> m [a] sepEndBy p sep = go id where go f = do@@ -254,7 +254,7 @@ -- | @'sepEndBy1' p sep@ parses /one/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a list of values returned by @p@.-sepEndBy1 :: MonadPlus m => m a -> m sep -> m [a]+sepEndBy1 :: (MonadPlus m) => m a -> m sep -> m [a] sepEndBy1 p sep = do x <- p more <- C.option False (True <$ sep)@@ -267,7 +267,7 @@ -- its result. -- -- See also: 'manyTill', 'skipManyTill'.-skipMany :: MonadPlus m => m a -> m ()+skipMany :: (MonadPlus m) => m a -> m () skipMany p = go where go = do@@ -279,7 +279,7 @@ -- result. -- -- See also: 'someTill', 'skipSomeTill'.-skipSome :: MonadPlus m => m a -> m ()+skipSome :: (MonadPlus m) => m a -> m () skipSome p = p >> skipMany p {-# INLINE skipSome #-} @@ -287,7 +287,7 @@ -- If @n@ is smaller or equal to zero, the parser equals to @'return' ()@. -- -- See also: 'count', 'count''.-skipCount :: Monad m => Int -> m a -> m ()+skipCount :: (Monad m) => Int -> m a -> m () skipCount n' p = go n' where go !n =@@ -300,7 +300,7 @@ -- then returned. -- -- See also: 'manyTill', 'skipMany'.-skipManyTill :: MonadPlus m => m a -> m end -> m end+skipManyTill :: (MonadPlus m) => m a -> m end -> m end skipManyTill p end = go where go = do@@ -315,6 +315,6 @@ -- then returned. -- -- See also: 'someTill', 'skipSome'.-skipSomeTill :: MonadPlus m => m a -> m end -> m end+skipSomeTill :: (MonadPlus m) => m a -> m end -> m end skipSomeTill p end = p >> skipManyTill p end {-# INLINE skipSomeTill #-}
Control/Monad/Combinators/Expr.hs view
@@ -93,7 +93,7 @@ -- > prefix name f = Prefix (f <$ symbol name) -- > postfix name f = Postfix (f <$ symbol name) makeExprParser ::- MonadPlus m =>+ (MonadPlus m) => -- | Term parser m a -> -- | Operator table, see 'Operator'@@ -105,7 +105,7 @@ -- | @addPrecLevel p ops@ adds the ability to parse operators in table @ops@ -- to parser @p@.-addPrecLevel :: MonadPlus m => m a -> [Operator m a] -> m a+addPrecLevel :: (MonadPlus m) => m a -> [Operator m a] -> m a addPrecLevel term ops = term' >>= \x -> choice [ras' x, las' x, nas' x, tern' x, return x] where@@ -120,7 +120,7 @@ -- | @pTerm prefix term postfix@ parses a @term@ surrounded by optional -- prefix and postfix unary operators. Parsers @prefix@ and @postfix@ are -- allowed to fail, in this case 'id' is used.-pTerm :: MonadPlus m => m (a -> a) -> m a -> m (a -> a) -> m a+pTerm :: (MonadPlus m) => m (a -> a) -> m a -> m (a -> a) -> m a pTerm prefix term postfix = do pre <- option id prefix x <- term@@ -131,7 +131,7 @@ -- | @pInfixN op p x@ parses non-associative infix operator @op@, then term -- with parser @p@, then returns result of the operator application on @x@ -- and the term.-pInfixN :: MonadPlus m => m (a -> a -> a) -> m a -> a -> m a+pInfixN :: (MonadPlus m) => m (a -> a -> a) -> m a -> a -> m a pInfixN op p x = do f <- op y <- p@@ -141,7 +141,7 @@ -- | @pInfixL op p x@ parses left-associative infix operator @op@, then term -- with parser @p@, then returns result of the operator application on @x@ -- and the term.-pInfixL :: MonadPlus m => m (a -> a -> a) -> m a -> a -> m a+pInfixL :: (MonadPlus m) => m (a -> a -> a) -> m a -> a -> m a pInfixL op p x = do f <- op y <- p@@ -152,7 +152,7 @@ -- | @pInfixR op p x@ parses right-associative infix operator @op@, then -- term with parser @p@, then returns result of the operator application on -- @x@ and the term.-pInfixR :: MonadPlus m => m (a -> a -> a) -> m a -> a -> m a+pInfixR :: (MonadPlus m) => m (a -> a -> a) -> m a -> a -> m a pInfixR op p x = do f <- op y <- p >>= \r -> pInfixR op p r <|> return r@@ -160,7 +160,7 @@ {-# INLINE pInfixR #-} -- | Parse the first separator of a ternary operator-pTernR :: MonadPlus m => m (m (a -> a -> a -> a)) -> m a -> a -> m a+pTernR :: (MonadPlus m) => m (m (a -> a -> a -> a)) -> m a -> a -> m a pTernR sep1 p x = do sep2 <- sep1 y <- p >>= \r -> pTernR sep1 p r `mplus` return r
Control/Monad/Combinators/NonEmpty.hs view
@@ -29,13 +29,13 @@ -- list of the values returned by @p@. -- -- > word = some letter-some :: MonadPlus m => m a -> m (NonEmpty a)+some :: (MonadPlus m) => m a -> m (NonEmpty a) some p = NE.fromList <$> C.some p {-# INLINE some #-} -- | @'endBy1' p sep@ parses /one/ or more occurrences of @p@, separated and -- ended by @sep@. Returns a non-empty list of values returned by @p@.-endBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)+endBy1 :: (MonadPlus m) => m a -> m sep -> m (NonEmpty a) endBy1 p sep = NE.fromList <$> C.endBy1 p sep {-# INLINE endBy1 #-} @@ -43,19 +43,19 @@ -- should succeed at least once. -- -- See also: 'C.skipSome', 'C.skipSomeTill'.-someTill :: MonadPlus m => m a -> m end -> m (NonEmpty a)+someTill :: (MonadPlus m) => m a -> m end -> m (NonEmpty a) someTill p end = NE.fromList <$> C.someTill p end {-# INLINE someTill #-} -- | @'sepBy1' p sep@ parses /one/ or more occurrences of @p@, separated by -- @sep@. Returns a non-empty list of values returned by @p@.-sepBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)+sepBy1 :: (MonadPlus m) => m a -> m sep -> m (NonEmpty a) sepBy1 p sep = NE.fromList <$> C.sepBy1 p sep {-# INLINE sepBy1 #-} -- | @'sepEndBy1' p sep@ parses /one/ or more occurrences of @p@, separated -- and optionally ended by @sep@. Returns a non-empty list of values returned by -- @p@.-sepEndBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)+sepEndBy1 :: (MonadPlus m) => m a -> m sep -> m (NonEmpty a) sepEndBy1 p sep = NE.fromList <$> C.sepEndBy1 p sep {-# INLINE sepEndBy1 #-}
Control/Monad/Permutations.hs view
@@ -11,7 +11,7 @@ -- considerations, depending on the monad the permutations are run over. -- -- For a more general interface requiring only 'Applicative', and for more--- complete documentation, see the 'Control.Applicative.Permutations' module.+-- complete documentation, see the "Control.Applicative.Permutations" module. -- -- @since 1.3.0 module Control.Monad.Permutations@@ -33,10 +33,10 @@ -- | An 'Applicative' wrapper-type for constructing permutation parsers. data Permutation m a = P !(Maybe a) (m (Permutation m a)) -instance Functor m => Functor (Permutation m) where+instance (Functor m) => Functor (Permutation m) where fmap f (P v p) = P (f <$> v) (fmap f <$> p) -instance Alternative m => Applicative (Permutation m) where+instance (Alternative m) => Applicative (Permutation m) where pure value = P (Just value) empty lhs@(P f v) <*> rhs@(P g w) = P (f <*> g) (lhsAlt <|> rhsAlt) where@@ -84,7 +84,7 @@ -- | \"Lifts\" a parser to a permutation parser. toPermutation ::- Alternative m =>+ (Alternative m) => -- | Permutation component m a -> Permutation m a@@ -95,7 +95,7 @@ -- If no permutation containing the supplied parser can be parsed from the input, -- then the supplied default value is returned in lieu of a parse result. toPermutationWithDefault ::- Alternative m =>+ (Alternative m) => -- | Default Value a -> -- | Permutation component
README.md view
@@ -4,7 +4,7 @@ [](https://hackage.haskell.org/package/parser-combinators) [](http://stackage.org/nightly/package/parser-combinators) [](http://stackage.org/lts/package/parser-combinators)-+[](https://github.com/mrkkrp/parser-combinators/actions/workflows/ci.yaml) The package provides common parser combinators defined in terms of `Applicative` and `Alternative` without any dependencies but `base`. There
− Setup.hs
@@ -1,6 +0,0 @@-module Main (main) where--import Distribution.Simple--main :: IO ()-main = defaultMain
parser-combinators.cabal view
@@ -1,14 +1,14 @@-cabal-version: 1.18+cabal-version: 2.4 name: parser-combinators-version: 1.3.0-license: BSD3+version: 1.3.1+license: BSD-3-Clause license-file: LICENSE.md maintainer: Mark Karpov <markkarpov92@gmail.com> author: Mark Karpov <markkarpov92@gmail.com> Alex Washburn <github@recursion.ninja> -tested-with: ghc ==8.6.5 ghc ==8.8.4 ghc ==8.10.3+tested-with: ghc ==9.8.4 ghc ==9.10.3 ghc ==9.12.1 homepage: https://github.com/mrkkrp/parser-combinators bug-reports: https://github.com/mrkkrp/parser-combinators/issues synopsis:@@ -43,15 +43,12 @@ Control.Monad.Permutations default-language: Haskell2010- build-depends: base >=4.12 && <5.0+ build-depends: base >=4.15 && <5 if flag(dev)- ghc-options: -Wall -Werror+ ghc-options:+ -Wall -Werror -Wredundant-constraints -Wpartial-fields+ -Wunused-packages else ghc-options: -O2 -Wall-- if flag(dev)- ghc-options:- -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns- -Wnoncanonical-monad-instances