polyparse 1.13 → 1.13.1
raw patch · 19 files changed
+186/−163 lines, 19 filesdep −faildep ~basenew-uploader
Dependencies removed: fail
Dependency ranges changed: base
Files
- Changelog.md +9/−1
- README.md +12/−0
- polyparse.cabal +48/−49
- src/Text/Parse.hs +18/−18
- src/Text/Parse/ByteString.hs +16/−16
- src/Text/ParserCombinators/HuttonMeijer.hs +7/−7
- src/Text/ParserCombinators/Poly/Base.hs +16/−16
- src/Text/ParserCombinators/Poly/ByteString.hs +1/−1
- src/Text/ParserCombinators/Poly/ByteStringChar.hs +1/−1
- src/Text/ParserCombinators/Poly/Lazy.hs +10/−8
- src/Text/ParserCombinators/Poly/Lex.hs +2/−2
- src/Text/ParserCombinators/Poly/Parser.hs +8/−8
- src/Text/ParserCombinators/Poly/Plain.hs +9/−9
- src/Text/ParserCombinators/Poly/Result.hs +1/−1
- src/Text/ParserCombinators/Poly/State.hs +8/−8
- src/Text/ParserCombinators/Poly/StateLazy.hs +10/−8
- src/Text/ParserCombinators/Poly/StateParser.hs +8/−8
- src/Text/ParserCombinators/Poly/StateText.hs +1/−1
- src/Text/ParserCombinators/Poly/Text.hs +1/−1
Changelog.md view
@@ -1,3 +1,11 @@+## 1.13.1++_Andreas Abel, 2025-09-14_++- Remove support for GHC 7.+- Add support for MicroHs.+- Build tested with GHC 8.0 - 9.14 alpha1.+ ## 1.13 - GHC-8.8 compatibility@@ -6,4 +14,4 @@ ## 1.12.1 - GHC-8.6 compatibility- - MonadFail instances+- MonadFail instances
+ README.md view
@@ -0,0 +1,12 @@+[](http://hackage.haskell.org/package/polyparse)+[](https://www.stackage.org/package/polyparse)+[](https://stackage.org/nightly/package/polyparse)+[](https://github.com/haskell-pkg-janitors/polyparse/actions)++# polyparse++A variety of alternative parser combinator libraries.++Description see: https://hackage.haskell.org/package/polyparse++Old homepage: https://archives.haskell.org/projects.haskell.org/polyparse/
polyparse.cabal view
@@ -1,81 +1,80 @@+cabal-version: 1.18 name: polyparse-version: 1.13+version: 1.13.1 license: LGPL-license-files: COPYRIGHT, LICENCE-LGPL, LICENCE-commercial+license-files: COPYRIGHT, LICENCE-LGPL, LICENCE-commercial copyright: (c) 2006-2016 Malcolm Wallace author: Malcolm Wallace <Malcolm.Wallace@me.com>-maintainer: author-homepage: http://code.haskell.org/~malcolm/polyparse/-bug-reports: https://github.com/haskell-infra/hackage-trustees/issues+maintainer: Andreas Abel+-- homepage:+bug-reports: https://github.com/haskell-pkg-janitors/polyparse/issues category: Text, Parsing synopsis: A variety of alternative parser combinator libraries. description:- This version, 1.13 is a Non-Maintainer Upload (NMU).- Report issues to the Hackage Trustees issue tracker.- . A variety of alternative parser combinator libraries, including the original HuttonMeijer set. The Poly sets have features like good error reporting, arbitrary token type, running state, lazy parsing, and so on. Finally, Text.Parse is a proposed replacement for the standard Read class, for better deserialisation of Haskell values from Strings.+ .+ Old homepage: <https://archives.haskell.org/projects.haskell.org/polyparse/>+ build-type: Simple-cabal-version: >=1.8-extra-source-files: Changelog.md +extra-doc-files:+ Changelog.md+ README.md+ tested-with:- GHC ==8.8.1- || ==8.6.5- || ==8.4.4- || ==8.2.2- || ==8.0.2- || ==7.10.3- || ==7.8.4- || ==7.6.3- || ==7.4.2- || ==7.2.2- || ==7.0.4+ GHC == 9.14.1+ GHC == 9.12.2+ GHC == 9.10.2+ GHC == 9.8.4+ GHC == 9.6.7+ GHC == 9.4.8+ GHC == 9.2.8+ GHC == 9.0.2+ GHC == 8.10.7+ GHC == 8.8.4+ GHC == 8.6.5+ GHC == 8.4.4+ GHC == 8.2.2+ GHC == 8.0.2 source-repository head- type: darcs- location: http://code.haskell.org/polyparse--source-repository this type: git- location: https://github.com/hackage-trustees/malcolm-wallace-universe.git- tag: 1.12.1+ location: https://github.com/haskell-pkg-janitors/polyparse.git library hs-source-dirs: src- build-depends: base >= 4.3.1.0 && < 4.14 - if !impl(ghc >= 8.0)- build-depends: fail == 4.9.*- exposed-modules:- Text.ParserCombinators.HuttonMeijer,- Text.ParserCombinators.HuttonMeijerWallace,- Text.ParserCombinators.Poly,- Text.ParserCombinators.Poly.Base,- Text.ParserCombinators.Poly.Result,- Text.ParserCombinators.Poly.Parser,- Text.ParserCombinators.Poly.Plain,- Text.ParserCombinators.Poly.Lazy,- Text.ParserCombinators.Poly.StateParser,- Text.ParserCombinators.Poly.State,- Text.ParserCombinators.Poly.StateLazy,- Text.ParserCombinators.Poly.Lex,+ Text.ParserCombinators.HuttonMeijer+ Text.ParserCombinators.HuttonMeijerWallace+ Text.ParserCombinators.Poly+ Text.ParserCombinators.Poly.Base+ Text.ParserCombinators.Poly.Result+ Text.ParserCombinators.Poly.Parser+ Text.ParserCombinators.Poly.Plain+ Text.ParserCombinators.Poly.Lazy+ Text.ParserCombinators.Poly.StateParser+ Text.ParserCombinators.Poly.State+ Text.ParserCombinators.Poly.StateLazy+ Text.ParserCombinators.Poly.Lex Text.Parse++ build-depends: base >= 4.9 && < 5+ if impl(ghc)- build-depends: bytestring >= 0.9.1.0 && < 0.11- build-depends: text >= 1.2.3.0 && <1.3+ build-depends: bytestring >= 0.9.1.0 && < 0.13+ build-depends: text >= 1.2.3.0 && < 1.3 || >= 2.0 && < 3 exposed-modules: Text.ParserCombinators.Poly.ByteString Text.ParserCombinators.Poly.ByteStringChar Text.Parse.ByteString Text.ParserCombinators.Poly.Text Text.ParserCombinators.Poly.StateText--- Text.Parse.Text- cpp-options: -DVERSION="1.12"- nhc98-options: -K6M- extensions: CPP++ default-language: Haskell2010+ default-extensions: CPP
src/Text/Parse.hs view
@@ -1,19 +1,19 @@ module Text.Parse- ( -- * The Parse class is a replacement for the standard Read class. + ( -- * The Parse class is a replacement for the standard Read class. -- $parser- TextParser -- synonym for Parser Char, i.e. string input, no state- , Parse(..) -- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],- -- Int, Integer, Float, Double, Char, Bool- , parseByRead -- :: Read a => String -> TextParser a+ TextParser -- synonym for Parser Char, i.e. string input, no state+ , Parse(..) -- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],+ -- Int, Integer, Float, Double, Char, Bool+ , parseByRead -- :: Read a => String -> TextParser a , readByParse -- :: TextParser a -> ReadS a , readsPrecByParsePrec -- :: (Int->TextParser a) -> Int -> ReadS a -- ** Combinators specific to string input, lexed haskell-style- , word -- :: TextParser String- , isWord -- :: String -> TextParser ()- , literal -- :: String -> TextParser ()- , optionalParens -- :: TextParser a -> TextParser a- , parens -- :: Bool -> TextParser a -> TextParser a- , field -- :: Parse a => String -> TextParser a+ , word -- :: TextParser String+ , isWord -- :: String -> TextParser ()+ , literal -- :: String -> TextParser ()+ , optionalParens -- :: TextParser a -> TextParser a+ , parens -- :: Bool -> TextParser a -> TextParser a+ , field -- :: Parse a => String -> TextParser a , constructors-- :: [(String,TextParser a)] -> TextParser a , enumeration -- :: Show a => String -> [a] -> TextParser a -- ** Parsers for literal numerics and characters@@ -65,7 +65,7 @@ parsePrec _ = optionalParens parse -- | Parsing a list of items by default accepts the [] and comma syntax, -- except when the list is really a character string using \"\".- parseList :: TextParser [a] -- only to distinguish [] and ""+ parseList :: TextParser [a] -- only to distinguish [] and "" parseList = do { isWord "[]"; return [] } `onFail` do { isWord "["; isWord "]"; return [] }@@ -237,7 +237,7 @@ parseInt base radix isDigit digitToInt = do cs <- many1 (satisfy isDigit) return (foldl1 (\n d-> n*radix+d)- (map (fromIntegral.digitToInt) cs))+ (map (fromIntegral . digitToInt) cs)) `adjustErr` (++("\nexpected one or more "++base++" digits")) parseDec, parseOct, parseHex :: (Integral a) => TextParser a parseDec = parseInt "decimal" 10 Char.isDigit Char.digitToInt@@ -252,10 +252,10 @@ `onFail` return [] ) exp <- exponent `onFail` return 0 ( return . fromRational . (* (10^^(exp - length frac)))- . (%1) . (\ (Right x)->x) . fst+ . (% 1) . (\ (Right x) -> x) . fst . runParser parseDec ) (ds++frac) `onFail`- do w <- many (satisfy (not.isSpace))+ do w <- many (satisfy (not . isSpace)) case map toLower w of "nan" -> return (0/0) "infinity" -> return (1/0)@@ -377,7 +377,7 @@ -- Basic types instance Parse Int where- -- parse = parseByRead "Int" -- convert from Integer, deals with minInt+ -- parse = parseByRead "Int" -- convert from Integer, deals with minInt parse = fmap fromInteger $ do many (satisfy isSpace); parseSigned parseDec instance Parse Integer where@@ -396,7 +396,7 @@ -- else fail "expected a char" } -- parseList = bracket (isWord "\"") (satisfy (=='"')) -- (many (satisfy (/='"')))- -- not totally correct for strings...+ -- not totally correct for strings... parseList = do { w <- word; if head w == '"' then return (init (tail w)) else fail "not a string" } @@ -441,7 +441,7 @@ parens (p>9) (do { isWord "Just" ; fmap Just $ parsePrec 10 `adjustErrBad` ("but within Just, "++) })- `adjustErr` (("expected a Maybe (Just or Nothing)\n"++).indent 2)+ `adjustErr` (("expected a Maybe (Just or Nothing)\n"++) . indent 2) instance (Parse a, Parse b) => Parse (Either a b) where parsePrec p =
src/Text/Parse/ByteString.hs view
@@ -1,20 +1,20 @@ module Text.Parse.ByteString- ( -- * The Parse class is a replacement for the standard Read class. + ( -- * The Parse class is a replacement for the standard Read class. -- This particular instance reads from ByteString rather than String. -- $parser- TextParser -- synonym for Text.ParserCombinators.Poly.ByteString- , Parse(..) -- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],- -- Int, Integer, Float, Double, Char, Bool- , parseByRead -- :: Read a => String -> TextParser a+ TextParser -- synonym for Text.ParserCombinators.Poly.ByteString+ , Parse(..) -- instances: (), (a,b), (a,b,c), Maybe a, Either a, [a],+ -- Int, Integer, Float, Double, Char, Bool+ , parseByRead -- :: Read a => String -> TextParser a , readByParse -- :: TextParser a -> ReadS a , readsPrecByParsePrec -- :: (Int->TextParser a) -> Int -> ReadS a -- ** Combinators specific to bytestring input, lexed haskell-style- , word -- :: TextParser String- , isWord -- :: String -> TextParser ()- , literal -- :: String -> TextParser ()- , optionalParens -- :: TextParser a -> TextParser a- , parens -- :: Bool -> TextParser a -> TextParser a- , field -- :: Parse a => String -> TextParser a+ , word -- :: TextParser String+ , isWord -- :: String -> TextParser ()+ , literal -- :: String -> TextParser ()+ , optionalParens -- :: TextParser a -> TextParser a+ , parens -- :: Bool -> TextParser a -> TextParser a+ , field -- :: Parse a => String -> TextParser a , constructors-- :: [(String,TextParser a)] -> TextParser a , enumeration -- :: Show a => String -> [a] -> TextParser a -- ** Parsers for literal numerics and characters@@ -72,7 +72,7 @@ parsePrec _ = optionalParens parse -- | Parsing a list of items by default accepts the [] and comma syntax, -- except when the list is really a character string using \"\".- parseList :: TextParser [a] -- only to distinguish [] and ""+ parseList :: TextParser [a] -- only to distinguish [] and "" parseList = do { isWord "[]"; return [] } `onFail` do { isWord "["; isWord "]"; return [] }@@ -271,7 +271,7 @@ parseInt base radix isDigit digitToInt = do cs <- many1 (satisfy isDigit) return (foldl1 (\n d-> n*radix+d)- (map (fromIntegral.digitToInt) cs))+ (map (fromIntegral . digitToInt) cs)) `adjustErr` (++("\nexpected one or more "++base++" digits")) -- | Parse a decimal, octal, or hexadecimal (unsigned) Integral numeric literal.@@ -301,7 +301,7 @@ `onFail` return BS.empty ) exp <- exponent `onFail` return 0 ( return . fromRational . (* (10^^(exp - BS.length frac)))- . (%1) . (\ (Right x)->x) . fst+ . (% 1) . (\ (Right x) -> x) . fst . runParser parseDec ) (ds `BS.append` frac) `onFail` do w <- manySatisfy isAlpha@@ -426,7 +426,7 @@ -- Basic types instance Parse Int where- parse = fmap fromInteger $ -- convert from Integer, deals with minInt+ parse = fmap fromInteger $ -- convert from Integer, deals with minInt do manySatisfy isSpace; parseSigned parseUnsignedInteger instance Parse Integer where parse = do manySatisfy isSpace; parseSigned parseUnsignedInteger@@ -436,7 +436,7 @@ parse = do manySatisfy isSpace; parseSigned parseFloat instance Parse Char where parse = do manySatisfy isSpace; parseLitChar'- -- not totally correct for strings...+ -- not totally correct for strings... parseList = do { w <- word; if head w == '"' then return (init (tail w)) else fail "not a string" }
src/Text/ParserCombinators/HuttonMeijer.hs view
@@ -3,25 +3,25 @@ -- Module : Text.ParserCombinators.HuttonMeijer -- Copyright : Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht) -- Licence : BSD--- +-- -- Maintainer : Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk> -- Stability : Stable -- Portability : All -- -- A LIBRARY OF MONADIC PARSER COMBINATORS--- +-- -- 29th July 1996--- +-- -- Graham Hutton Erik Meijer -- University of Nottingham University of Utrecht--- +-- -- This Haskell script defines a library of parser combinators, and is -- taken from sections 1-6 of our article "Monadic Parser Combinators". -- Some changes to the library have been made in the move from Gofer -- to Haskell:--- +-- -- * Do notation is used in place of monad comprehension notation;--- +-- -- * The parser datatype is defined using "newtype", to avoid the overhead -- of tagging and untagging parsers with the P constructor. -----------------------------------------------------------------------------@@ -195,7 +195,7 @@ comment :: Parser () --comment = do {string "--"; many (sat (\x -> x /= '\n')); return ()}---comment = do +--comment = do -- _ <- string "--" -- _ <- many (sat (\x -> x /= '\n')) -- return ()
src/Text/ParserCombinators/Poly/Base.hs view
@@ -1,26 +1,26 @@ module Text.ParserCombinators.Poly.Base ( -- * The PolyParse classes- Commitment(..) -- class of all two-level-error values- , PolyParse -- class of all monadic two-level-error parsers+ Commitment(..) -- class of all two-level-error values+ , PolyParse -- class of all monadic two-level-error parsers -- * Combinators general to all parser types. -- ** Simple combinators- , apply -- :: PolyParse p => p (a->b) -> p a -> p b- , discard -- :: PolyParse p => p a -> p b -> p a+ , apply -- :: PolyParse p => p (a->b) -> p a -> p b+ , discard -- :: PolyParse p => p a -> p b -> p a -- ** Error-handling- , failBad -- :: PolyParse p => String -> p a+ , failBad -- :: PolyParse p => String -> p a , adjustErrBad-- :: PolyParse p => p a -> (String->String) -> p a- , indent -- :: Int -> String -> String+ , indent -- :: Int -> String -> String -- ** Choices- , oneOf -- :: PolyParse p => [p a] -> p a+ , oneOf -- :: PolyParse p => [p a] -> p a -- ** Sequences- , exactly -- :: PolyParse p => Int -> p a -> p [a]- , upto -- :: PolyParse p => Int -> p a -> p [a]- , many1 -- :: PolyParse p => p a -> p [a]- , sepBy -- :: PolyParse p => p a -> p sep -> p [a]- , sepBy1 -- :: PolyParse p => p a -> p sep -> p [a]- , bracketSep -- :: PolyParse p => p bra -> p sep -> p ket -> p a -> p [a]- , bracket -- :: PolyParse p => p bra -> p ket -> p a -> p a+ , exactly -- :: PolyParse p => Int -> p a -> p [a]+ , upto -- :: PolyParse p => Int -> p a -> p [a]+ , many1 -- :: PolyParse p => p a -> p [a]+ , sepBy -- :: PolyParse p => p a -> p sep -> p [a]+ , sepBy1 -- :: PolyParse p => p a -> p sep -> p [a]+ , bracketSep -- :: PolyParse p => p bra -> p sep -> p ket -> p a -> p [a]+ , bracket -- :: PolyParse p => p bra -> p ket -> p a -> p a , manyFinally -- :: PolyParse p => p a -> p z -> p [a] , manyFinally'-- :: PolyParse p => p a -> p z -> p [a] ) where@@ -29,7 +29,7 @@ import qualified Control.Monad.Fail as Fail #ifdef __NHC__-default (Integer,Double,[]) -- hack to avoid bizarre type defaulting error+default (Integer,Double,[]) -- hack to avoid bizarre type defaulting error instance Commitment [] instance PolyParse [] #endif@@ -165,7 +165,7 @@ ; return (x:) `apply` many (do {sep; p}) } `adjustErr` ("When looking for a non-empty sequence with separators:\n\t"++)- + -- | Parse a list of items, discarding the start, end, and separator -- items. bracketSep :: PolyParse p => p bra -> p sep -> p ket -> p a -> p [a]
src/Text/ParserCombinators/Poly/ByteString.hs view
@@ -119,7 +119,7 @@ onFail :: Parser a -> Parser a -> Parser a (P p) `onFail` (P q) = P (\ts-> continue ts $ p ts) where continue ts (Failure _ _) = q ts- -- continue _ (Committed r) = r -- no, remain Committed+ -- continue _ (Committed r) = r -- no, remain Committed continue _ r = r ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/ByteStringChar.hs view
@@ -118,7 +118,7 @@ onFail :: Parser a -> Parser a -> Parser a (P p) `onFail` (P q) = P (\ts-> continue ts $ p ts) where continue ts (Failure _ _) = q ts- -- continue _ (Committed r) = r -- no, remain Committed+ -- continue _ (Committed r) = r -- no, remain Committed continue _ r = r ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/Lazy.hs view
@@ -1,18 +1,18 @@ {-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-} module Text.ParserCombinators.Poly.Lazy ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the parser monad- , runParser -- :: Parser t a -> [t] -> (Either String a, [t])+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the parser monad+ , runParser -- :: Parser t a -> [t] -> (Either String a, [t]) -- ** Basic parsers- , next -- :: Parser t t- , eof -- :: Parser t ()- , satisfy -- :: (t->Bool) -> Parser t t- , satisfyMsg -- :: (t->Bool) -> String -> Parser t t+ , next -- :: Parser t t+ , eof -- :: Parser t ()+ , satisfy -- :: (t->Bool) -> Parser t t+ , satisfyMsg -- :: (t->Bool) -> String -> Parser t t , onFail -- :: Parser t a -> Parser t a -> Parser t a -- ** Re-parsing- , reparse -- :: [t] -> Parser t ()+ , reparse -- :: [t] -> Parser t () -- * Re-export all more general combinators , module Text.ParserCombinators.Poly.Base , module Control.Applicative@@ -45,7 +45,9 @@ fmap f (P p) = P (fmap f p) instance Monad (Parser t) where return x = P (return x)+#ifndef __MHS__ fail = Fail.fail+#endif (P f) >>= g = P (f >>= (\(P g')->g') . g) instance Fail.MonadFail (Parser t) where fail e = P (fail e)
src/Text/ParserCombinators/Poly/Lex.hs view
@@ -35,7 +35,7 @@ -- | In a strict language, where creating the entire input list of tokens -- in one shot may be infeasible, we can use a lazy "callback" kind of -- architecture instead. The lexer returns a single token at a time,--- together with a continuation. The @next@ parser is responsible for +-- together with a continuation. The @next@ parser is responsible for -- pulling on the token stream, applying the continuation where necessary. data LexReturn t = LexReturn t String (String->LexReturn t) | LexFinish@@ -93,7 +93,7 @@ r@(Committed _) -> r ) showErr (name,err) = name ++ "\n" ++ indent 2 err -infixl 6 `onFail` -- not sure about precedence 6?+infixl 6 `onFail` -- not sure about precedence 6? -- | @p `onFail` q@ means parse p, unless p fails, in which case -- parse q instead.
src/Text/ParserCombinators/Poly/Parser.hs view
@@ -4,17 +4,17 @@ -- via T.P.Poly.Plain or T.P.Poly.Lazy. module Text.ParserCombinators.Poly.Parser ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the Parser Monad.+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the Parser Monad. -- ** Basic parsers- , next -- :: Parser t t- , eof -- :: Parser t ()- , satisfy -- :: (t->Bool) -> Parser t t- , satisfyMsg -- :: Show t => (t->Bool) -> String -> Parser t t+ , next -- :: Parser t t+ , eof -- :: Parser t ()+ , satisfy -- :: (t->Bool) -> Parser t t+ , satisfyMsg -- :: Show t => (t->Bool) -> String -> Parser t t , onFail -- :: Parser t a -> Parser t a -> Parser t a -- ** Re-parsing- , reparse -- :: [t] -> Parser t ()+ , reparse -- :: [t] -> Parser t () ) where import Text.ParserCombinators.Poly.Base@@ -83,7 +83,7 @@ r@(Committed _) -> r ) showErr (name,err) = name++":\n"++indent 2 err -infixl 6 `onFail` -- not sure about precedence 6?+infixl 6 `onFail` -- not sure about precedence 6? -- | @p `onFail` q@ means parse p, unless p fails, in which case -- parse q instead.
src/Text/ParserCombinators/Poly/Plain.hs view
@@ -1,17 +1,17 @@ module Text.ParserCombinators.Poly.Plain ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the Parser Monad.- , runParser -- :: Parser t a -> [t] -> (Either String a, [t])+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the Parser Monad.+ , runParser -- :: Parser t a -> [t] -> (Either String a, [t]) -- ** Basic parsers- , next -- :: Parser t t- , eof -- :: Parser t ()- , satisfy -- :: (t->Bool) -> Parser t t- , satisfyMsg -- :: (t->Bool) -> String -> Parser t t- , onFail -- :: Parser t a -> Parser t a -> Parser t a+ , next -- :: Parser t t+ , eof -- :: Parser t ()+ , satisfy -- :: (t->Bool) -> Parser t t+ , satisfyMsg -- :: (t->Bool) -> String -> Parser t t+ , onFail -- :: Parser t a -> Parser t a -> Parser t a -- ** Re-parsing- , reparse -- :: [t] -> Parser t ()+ , reparse -- :: [t] -> Parser t () -- * Re-export all more general combinators , module Text.ParserCombinators.Poly.Base , module Control.Applicative
src/Text/ParserCombinators/Poly/Result.hs view
@@ -1,6 +1,6 @@ module Text.ParserCombinators.Poly.Result ( -- * The parsing result type- Result(..) -- A parsing result type, with Success, Failure, and Commitment.+ Result(..) -- A parsing result type, with Success, Failure, and Commitment. , resultToEither ) where
src/Text/ParserCombinators/Poly/State.hs view
@@ -1,19 +1,19 @@ module Text.ParserCombinators.Poly.State ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the parser monad- , runParser -- :: Parser s t a -> s -> [t] -> (Either String a, s, [t])+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the parser monad+ , runParser -- :: Parser s t a -> s -> [t] -> (Either String a, s, [t]) -- ** Basic parsers- , next -- :: Parser s t t- , eof -- :: Parser s t ()- , satisfy -- :: (t->Bool) -> Parser s t t- , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a+ , next -- :: Parser s t t+ , eof -- :: Parser s t ()+ , satisfy -- :: (t->Bool) -> Parser s t t+ , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a -- ** State-handling , stUpdate -- :: (s->s) -> Parser s t () , stQuery -- :: (s->a) -> Parser s t a , stGet -- :: Parser s t s -- ** Re-parsing- , reparse -- :: [t] -> Parser s t ()+ , reparse -- :: [t] -> Parser s t () -- * Re-export all more general combinators , module Text.ParserCombinators.Poly.Base , module Control.Applicative
src/Text/ParserCombinators/Poly/StateLazy.hs view
@@ -1,21 +1,21 @@ {-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-} module Text.ParserCombinators.Poly.StateLazy ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the parser monad- , runParser -- :: Parser s t a -> s -> [t] -> (Either String a, s, [t])+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the parser monad+ , runParser -- :: Parser s t a -> s -> [t] -> (Either String a, s, [t]) -- ** Basic parsers- , next -- :: Parser s t t- , eof -- :: Parser s t ()- , satisfy -- :: (t->Bool) -> Parser s t t+ , next -- :: Parser s t t+ , eof -- :: Parser s t ()+ , satisfy -- :: (t->Bool) -> Parser s t t , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a- , manyFinally -- :: Parser s t a -> Parser s t z -> Parser s t [a]+ , manyFinally -- :: Parser s t a -> Parser s t z -> Parser s t [a] -- ** State-handling , stUpdate -- :: (s->s) -> Parser s t () , stQuery -- :: (s->a) -> Parser s t a , stGet -- :: Parser s t s -- ** Re-parsing- , reparse -- :: [t] -> Parser s t ()+ , reparse -- :: [t] -> Parser s t () -- * Re-export all more general combinators , module Text.ParserCombinators.Poly.Base , module Control.Applicative@@ -49,7 +49,9 @@ fmap f (P p) = P (fmap f p) instance Monad (Parser s t) where return x = P (return x)+#ifndef __MHS__ fail = Fail.fail+#endif (P f) >>= g = P (f >>= (\(P g')->g') . g) instance Fail.MonadFail (Parser s t) where fail e = P (fail e)
src/Text/ParserCombinators/Poly/StateParser.hs view
@@ -4,19 +4,19 @@ -- via T.P.Poly.State or T.P.Poly.StateLazy. module Text.ParserCombinators.Poly.StateParser ( -- * The Parser datatype- Parser(P) -- datatype, instance of: Functor, Monad, PolyParse- , Result(..) -- internal to the parser monad+ Parser(P) -- datatype, instance of: Functor, Monad, PolyParse+ , Result(..) -- internal to the parser monad -- ** basic parsers- , next -- :: Parser s t t- , eof -- :: Parser s t ()- , satisfy -- :: (t->Bool) -> Parser s t t+ , next -- :: Parser s t t+ , eof -- :: Parser s t ()+ , satisfy -- :: (t->Bool) -> Parser s t t , onFail -- :: Parser s t a -> Parser s t a -> Parser s t a -- ** State-handling , stUpdate -- :: (s->s) -> Parser s t () , stQuery -- :: (s->a) -> Parser s t a , stGet -- :: Parser s t s -- ** re-parsing- , reparse -- :: [t] -> Parser s t ()+ , reparse -- :: [t] -> Parser s t () ) where @@ -86,7 +86,7 @@ r@(Committed _) -> r ) showErr (name,err) = name++":\n"++indent 2 err -infixl 6 `onFail` -- not sure about precedence 6?+infixl 6 `onFail` -- not sure about precedence 6? -- | @p `onFail` q@ means parse p, unless p fails, in which case -- parse q instead.@@ -98,7 +98,7 @@ (P p) `onFail` (P q) = P (\s ts-> continue s ts $ p s ts) where continue s ts (Failure _ _) = q s ts- -- continue _ _ (Committed r) = r -- no, remain Committed+ -- continue _ _ (Committed r) = r -- no, remain Committed continue _ _ r = r ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/StateText.hs view
@@ -125,7 +125,7 @@ onFail :: Parser s a -> Parser s a -> Parser s a (P p) `onFail` (P q) = P (\s ts-> continue s ts $ p s ts) where continue s ts (Failure _ _) = q s ts- -- continue _ _ (Committed r) = r -- no, remain Committed+ -- continue _ _ (Committed r) = r -- no, remain Committed continue _ _ r = r ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/Text.hs view
@@ -119,7 +119,7 @@ onFail :: Parser a -> Parser a -> Parser a (P p) `onFail` (P q) = P (\ts-> continue ts $ p ts) where continue ts (Failure _ _) = q ts- -- continue _ (Committed r) = r -- no, remain Committed+ -- continue _ (Committed r) = r -- no, remain Committed continue _ r = r ------------------------------------------------------------------------