polyparse 1.10 → 1.11
raw patch · 8 files changed
+55/−29 lines, 8 filesdep ~base
Dependency ranges changed: base
Files
- COPYRIGHT +7/−0
- polyparse.cabal +2/−2
- src/Text/ParserCombinators/HuttonMeijer.hs +9/−0
- src/Text/ParserCombinators/HuttonMeijerWallace.hs +9/−0
- src/Text/ParserCombinators/Poly/Parser.hs +14/−1
- src/Text/ParserCombinators/Poly/Plain.hs +0/−13
- src/Text/ParserCombinators/Poly/State.hs +0/−13
- src/Text/ParserCombinators/Poly/StateParser.hs +14/−0
COPYRIGHT view
@@ -22,6 +22,13 @@ complied with. ---- +If you have a commercial use for polyparse, and feel that even the terms+of the LGPL (as relaxed above) are too onerous, you have the option of+distributing unmodified binaries (only, not sources) under the terms of+a different licence (see LICENCE-commercial).++----+ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
polyparse.cabal view
@@ -1,5 +1,5 @@ name: polyparse-version: 1.10+version: 1.11 license: LGPL license-file: COPYRIGHT author: Malcolm Wallace <Malcolm.Wallace@me.com>@@ -44,6 +44,6 @@ Text.ParserCombinators.Poly.Text Text.ParserCombinators.Poly.StateText -- Text.Parse.Text- cpp-options: -DVERSION="1.10"+ cpp-options: -DVERSION="1.11" nhc98-options: -K6M extensions: CPP
src/Text/ParserCombinators/HuttonMeijer.hs view
@@ -35,6 +35,7 @@ skip, token, natural, integer, symbol, identifier) where import Data.Char+import Control.Applicative ( Applicative(pure,(<*>)), Alternative(empty,(<|>)) ) import Control.Monad infixr 5 +++@@ -50,6 +51,10 @@ -- map :: (a -> b) -> (Parser a -> Parser b) fmap f (P p) = P (\inp -> [(f v, out) | (v,out) <- p inp]) +instance Applicative Parser where+ pure = return+ (<*>) = ap+ instance Monad Parser where -- return :: a -> Parser a return v = P (\inp -> [(v,inp)])@@ -59,6 +64,10 @@ -- fail :: String -> Parser a fail _ = P (\_ -> [])++instance Alternative Parser where+ empty = mzero+ (<|>) = mplus instance MonadPlus Parser where -- mzero :: Parser a
src/Text/ParserCombinators/HuttonMeijerWallace.hs view
@@ -54,6 +54,7 @@ ) where import Data.Char+import Control.Applicative ( Applicative(pure,(<*>)), Alternative(empty,(<|>)) ) import Control.Monad infixr 5 +++@@ -74,6 +75,10 @@ Left err -> Left err ) +instance Applicative (Parser s t e) where+ pure = return+ (<*>) = ap+ instance Monad (Parser s t e) where -- return :: a -> Parser s t e a return v = P (\st inp -> Right [(v,st,inp)])@@ -86,6 +91,10 @@ -- fail :: String -> Parser s t e a fail err = P (\st inp -> Right []) -- I know it's counterintuitive, but we want no-parse, not an error.++instance Alternative (Parser s t e) where+ empty = mzero+ (<|>) = mplus instance MonadPlus (Parser s t e) where -- mzero :: Parser s t e a
src/Text/ParserCombinators/Poly/Parser.hs view
@@ -17,9 +17,9 @@ , reparse -- :: [t] -> Parser t () ) where - import Text.ParserCombinators.Poly.Base import Text.ParserCombinators.Poly.Result+import Control.Applicative -- | This @Parser@ datatype is a fairly generic parsing monad with error -- reporting. It can be used for arbitrary token types, not just@@ -30,6 +30,13 @@ instance Functor (Parser t) where fmap f (P p) = P (fmap f . p) +instance Applicative (Parser t) where+ pure f = return f+ pf <*> px = do { f <- pf; x <- px; return (f x) }+#if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610+ p <* q = p `discard` q+#endif+ instance Monad (Parser t) where return x = P (\ts-> Success ts x) fail e = P (\ts-> Failure ts e)@@ -38,6 +45,12 @@ continue (Success ts x) = let (P g') = g x in g' ts continue (Committed r) = Committed (continue r) continue (Failure ts e) = Failure ts e++instance Alternative (Parser t) where+ empty = fail "no parse"+ p <|> q = p `onFail` q++instance PolyParse (Parser t) instance Commitment (Parser t) where commit (P p) = P (Committed . squash . p)
src/Text/ParserCombinators/Poly/Plain.hs view
@@ -29,17 +29,4 @@ runParser :: Parser t a -> [t] -> (Either String a, [t]) runParser (P p) = resultToEither . p -instance Applicative (Parser t) where- pure f = return f- pf <*> px = do { f <- pf; x <- px; return (f x) }-#if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610- p <* q = p `discard` q-#endif--instance Alternative (Parser t) where- empty = fail "no parse"- p <|> q = p `onFail` q--instance PolyParse (Parser t)- ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/State.hs view
@@ -34,17 +34,4 @@ where reTuple (either, (z,s)) = (either, s, z) -instance Applicative (Parser s t) where- pure f = return f- pf <*> px = do { f <- pf; x <- px; return (f x) }-#if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610- p <* q = p `discard` q-#endif--instance Alternative (Parser s t) where- empty = fail "no parse"- p <|> q = p `onFail` q--instance PolyParse (Parser s t)- ------------------------------------------------------------------------
src/Text/ParserCombinators/Poly/StateParser.hs view
@@ -22,6 +22,7 @@ import Text.ParserCombinators.Poly.Base import Text.ParserCombinators.Poly.Result+import Control.Applicative -- | This @Parser@ datatype is a fairly generic parsing monad with error -- reporting, and running state.@@ -32,6 +33,13 @@ instance Functor (Parser s t) where fmap f (P p) = P (\s-> fmap f . p s) +instance Applicative (Parser s t) where+ pure f = return f+ pf <*> px = do { f <- pf; x <- px; return (f x) }+#if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610+ p <* q = p `discard` q+#endif+ instance Monad (Parser s t) where return x = P (\s ts-> Success (ts,s) x) fail e = P (\s ts-> Failure (ts,s) e)@@ -40,6 +48,12 @@ continue (Success (ts,s) x) = let (P g') = g x in g' s ts continue (Committed r) = Committed (continue r) continue (Failure tss e) = Failure tss e++instance Alternative (Parser s t) where+ empty = fail "no parse"+ p <|> q = p `onFail` q++instance PolyParse (Parser s t) instance Commitment (Parser s t) where commit (P p) = P (\s-> Committed . squash . p s)