packages feed

polyparse 1.12 → 1.12.1

raw patch · 13 files changed

+125/−55 lines, 13 filesdep +faildep ~basedep ~bytestringdep ~textnew-uploader

Dependencies added: fail

Dependency ranges changed: base, bytestring, text

Files

+ Changelog.md view
@@ -0,0 +1,4 @@+## 1.12.1++- GHC-8.6 compatibility+    - MonadFail instances
polyparse.cabal view
@@ -1,31 +1,55 @@-name:		polyparse-version:	1.12-license:	LGPL-license-file:	COPYRIGHT-copyright:	(c) 2006-2016 Malcolm Wallace-author:		Malcolm Wallace <Malcolm.Wallace@me.com>-maintainer:	author-homepage:	http://code.haskell.org/~malcolm/polyparse/-category:	Text, Parsing-synopsis:	A variety of alternative parser combinator libraries.+name:           polyparse+version:        1.12.1+license:        LGPL+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+category:       Text, Parsing+synopsis:       A variety of alternative parser combinator libraries. description:-	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.-build-type:	Simple-cabal-version:  >=1.6-extra-source-files: LICENCE-LGPL, LICENCE-commercial+        This version, 1.12.1 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.+build-type:     Simple+cabal-version:  >=1.8+extra-source-files: Changelog.md +tested-with:+  GHC ==8.6.1+   || ==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+ source-repository head   type:     darcs   location: http://code.haskell.org/polyparse +source-repository this+  type:      git+  location:  https://github.com/hackage-/malcolm-wallace-universe.git+  tag:       1.12.1+ library-  hs-source-dirs:	src-  build-depends:	base <= 6+  hs-source-dirs:       src+  build-depends:        base >= 4.3.1.0 && < 4.13++  if !impl(ghc >= 8.0)+     build-depends: fail == 4.9.*+   exposed-modules:         Text.ParserCombinators.HuttonMeijer,         Text.ParserCombinators.HuttonMeijerWallace,@@ -41,8 +65,8 @@         Text.ParserCombinators.Poly.Lex,         Text.Parse   if impl(ghc)-    build-depends:	bytestring-    build-depends:	 text+    build-depends:      bytestring >= 0.9.1.0 && < 0.11+    build-depends:      text >= 1.2.3.0 && <1.3     exposed-modules:         Text.ParserCombinators.Poly.ByteString         Text.ParserCombinators.Poly.ByteStringChar@@ -50,6 +74,6 @@         Text.ParserCombinators.Poly.Text         Text.ParserCombinators.Poly.StateText --      Text.Parse.Text-  cpp-options:		-DVERSION="1.12"-  nhc98-options:	-K6M-  extensions:		CPP+  cpp-options:          -DVERSION="1.12"+  nhc98-options:        -K6M+  extensions:           CPP
src/Text/ParserCombinators/HuttonMeijer.hs view
@@ -37,6 +37,7 @@ import Data.Char import Control.Applicative ( Applicative(pure,(<*>)), Alternative(empty,(<|>)) ) import Control.Monad+import qualified Control.Monad.Fail as Fail  infixr 5 +++ @@ -52,16 +53,19 @@    fmap f (P p)    = P (\inp -> [(f v, out) | (v,out) <- p inp])  instance Applicative Parser where-   pure  = return+   pure v        = P (\inp -> [(v,inp)])    (<*>) = ap  instance Monad Parser where    -- return      :: a -> Parser a-   return v        = P (\inp -> [(v,inp)])+   return          = pure     -- >>=         :: Parser a -> (a -> Parser b) -> Parser b    (P p) >>= f     = P (\inp -> concat [papply (f v) out | (v,out) <- p inp]) +   fail            = Fail.fail++instance Fail.MonadFail Parser where    -- fail        :: String -> Parser a    fail _          = P (\_ -> []) 
src/Text/ParserCombinators/HuttonMeijerWallace.hs view
@@ -56,6 +56,7 @@ import Data.Char import Control.Applicative ( Applicative(pure,(<*>)), Alternative(empty,(<|>)) ) import Control.Monad+import qualified Control.Monad.Fail as Fail  infixr 5 +++ @@ -76,18 +77,21 @@                        )  instance Applicative (Parser s t e) where-   pure  = return+   pure v = P (\st inp -> Right [(v,st,inp)])    (<*>) = ap  instance Monad (Parser s t e) where    -- return      :: a -> Parser s t e a-   return v        = P (\st inp -> Right [(v,st,inp)])+   return          = pure    -- >>=         :: Parser s t e a -> (a -> Parser s t e b) -> Parser s t e b    (P p) >>= f     = P (\st inp -> case p st inp of                         Right res -> foldr joinresults (Right [])                             [ papply' (f v) s out | (v,s,out) <- res ]                         Left err  -> Left err                        )+   fail            = Fail.fail++instance Fail.MonadFail (Parser s t e) where    -- 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.
src/Text/ParserCombinators/Poly/ByteString.hs view
@@ -23,6 +23,7 @@ import qualified Data.ByteString.Lazy as BS import Data.ByteString.Lazy (ByteString) import Control.Applicative+import qualified Control.Monad.Fail as Fail import Data.Word  -- | This @Parser@ datatype is a specialised parsing monad with error@@ -38,14 +39,17 @@     fmap f (P p) = P (fmap f . p)  instance Monad Parser where-    return x     = P (\ts-> Success ts x)-    fail e       = P (\ts-> Failure ts e)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (continue . f)       where         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 Fail.MonadFail Parser where+    fail e       = P (\ts-> Failure ts e)+ instance Commitment Parser where     commit (P p)         = P (Committed . squash . p)       where@@ -71,7 +75,7 @@             showErr (name,err) = name++":\n"++indent 2 err  instance Applicative Parser where-    pure f    = return f+    pure x    = P (\ts-> Success ts x)     pf <*> px = do { f <- pf; x <- px; return (f x) } #if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610     p  <*  q  = p `discard` q
src/Text/ParserCombinators/Poly/ByteStringChar.hs view
@@ -23,6 +23,7 @@ import qualified Data.ByteString.Lazy.Char8 as BS import Data.ByteString.Lazy.Char8 (ByteString) import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | This @Parser@ datatype is a specialised parsing monad with error --   reporting.  Whereas the standard version can be used for arbitrary@@ -37,14 +38,17 @@     fmap f (P p) = P (fmap f . p)  instance Monad Parser where-    return x     = P (\ts-> Success ts x)-    fail e       = P (\ts-> Failure ts e)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (continue . f)       where         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 Fail.MonadFail Parser where+    fail e       = P (\ts-> Failure ts e)+ instance Commitment Parser where     commit (P p)         = P (Committed . squash . p)       where@@ -70,7 +74,7 @@             showErr (name,err) = name++":\n"++indent 2 err  instance Applicative Parser where-    pure f    = return f+    pure x    = P (\ts-> Success ts x)     pf <*> px = do { f <- pf; x <- px; return (f x) } #if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610     p  <*  q  = p `discard` q
src/Text/ParserCombinators/Poly/Lazy.hs view
@@ -22,6 +22,7 @@ import Text.ParserCombinators.Poly.Result import qualified Text.ParserCombinators.Poly.Parser as P import Control.Applicative+import qualified Control.Monad.Fail as Fail  #if __GLASGOW_HASKELL__ import Control.Exception hiding (bracket)@@ -38,14 +39,16 @@ --   to have a different instance. newtype Parser t a = P (P.Parser t a) #ifdef __GLASGOW_HASKELL__-        deriving (Functor,Monad,Commitment)+        deriving (Functor,Monad,Fail.MonadFail,Commitment) #else instance Functor (Parser t) where     fmap f (P p) = P (fmap f p) instance Monad (Parser t) where     return x  = P (return x)-    fail e    = P (fail e)+    fail      = Fail.fail     (P f) >>= g = P (f >>= (\(P g')->g') . g)+instance Fail.MonadFail (Parser t) where+    fail e    = P (fail e) instance Commitment (Parser t) where     commit (P p)   = P (commit p)     (P p) `adjustErr` f  = P (p `adjustErr` f)
src/Text/ParserCombinators/Poly/Lex.hs view
@@ -30,6 +30,7 @@ import Text.ParserCombinators.Poly.Base import Text.ParserCombinators.Poly.Result import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | 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@@ -54,14 +55,17 @@     fmap f (P p) = P (fmap f . p)  instance Monad (Parser t) where-    return x     = P (\ts-> Success ts x)-    fail e       = P (\ts-> Failure ts e)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (continue . f)       where         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 Fail.MonadFail  (Parser t) where+    fail e       = P (\ts-> Failure ts e)+ instance Commitment (Parser t) where     commit (P p)         = P (Committed . squash . p)       where@@ -101,7 +105,7 @@         continue _  r             = r  instance Applicative (Parser t) where-    pure f    = return f+    pure x    = P (\ts-> Success ts x)     pf <*> px = do { f <- pf; x <- px; return (f x) } #if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610     p  <*  q  = p `discard` q
src/Text/ParserCombinators/Poly/Parser.hs view
@@ -20,6 +20,7 @@ import Text.ParserCombinators.Poly.Base import Text.ParserCombinators.Poly.Result import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | This @Parser@ datatype is a fairly generic parsing monad with error --   reporting.  It can be used for arbitrary token types, not just@@ -31,20 +32,23 @@     fmap f (P p) = P (fmap f . p)  instance Applicative (Parser t) where-    pure f    = return f+    pure x    = P (\ts-> Success ts x)     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)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (continue . f)       where         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 Fail.MonadFail (Parser t) where+    fail e       = P (\ts-> Failure ts e)  instance Alternative (Parser t) where     empty     = fail "no parse"
src/Text/ParserCombinators/Poly/StateLazy.hs view
@@ -26,6 +26,7 @@ import Text.ParserCombinators.Poly.Result import qualified Text.ParserCombinators.Poly.StateParser as P import Control.Applicative+import qualified Control.Monad.Fail as Fail  #if __GLASGOW_HASKELL__ import Control.Exception hiding (bracket)@@ -42,14 +43,16 @@ --   to have a different instance. newtype Parser s t a = P (P.Parser s t a) #ifdef __GLASGOW_HASKELL__-        deriving (Functor,Monad,Commitment)+        deriving (Functor,Monad,Fail.MonadFail,Commitment) #else instance Functor (Parser s t) where     fmap f (P p) = P (fmap f p) instance Monad (Parser s t) where     return x  = P (return x)-    fail e    = P (fail e)+    fail      = Fail.fail     (P f) >>= g = P (f >>= (\(P g')->g') . g)+instance Fail.MonadFail (Parser s t) where+    fail e    = P (fail e) instance Commitment (Parser s t) where     commit (P p)   = P (commit p)     (P p) `adjustErr` f  = P (p `adjustErr` f)
src/Text/ParserCombinators/Poly/StateParser.hs view
@@ -23,6 +23,7 @@ import Text.ParserCombinators.Poly.Base import Text.ParserCombinators.Poly.Result import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | This @Parser@ datatype is a fairly generic parsing monad with error --   reporting, and running state.@@ -34,20 +35,23 @@     fmap f (P p) = P (\s-> fmap f . p s)  instance Applicative (Parser s t) where-    pure f    = return f+    pure x    = P (\s ts-> Success (ts,s) x)     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)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (\s-> continue . f s)       where         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 Fail.MonadFail (Parser s t) where+    fail e       = P (\s ts-> Failure (ts,s) e)  instance Alternative (Parser s t) where     empty     = fail "no parse"
src/Text/ParserCombinators/Poly/StateText.hs view
@@ -28,6 +28,7 @@ import qualified Data.Text.Lazy as T import Data.Text.Lazy (Text) import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | This @Parser@ datatype is a specialised parsing monad with error --   reporting.  Whereas the standard version can be used for arbitrary@@ -44,14 +45,17 @@     fmap f (P p) = P (\s-> fmap f . p s)  instance Monad (Parser s) where-    return x     = P (\s ts-> Success (ts,s) x)-    fail e       = P (\s ts-> Failure (ts,s) e)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (\s-> continue . f s)       where         continue (Success (ts,s) x)         = let (P g') = g x in g' s ts         continue (Committed r)              = Committed (continue r)         continue (Failure ts e)             = Failure ts e +instance Fail.MonadFail (Parser s) where+    fail e       = P (\s ts-> Failure (ts,s) e)+ instance Commitment (Parser s) where     commit (P p)         = P (\s-> Committed . squash . p s)       where@@ -77,7 +81,7 @@             showErr (name,err) = name++":\n"++indent 2 err  instance Applicative (Parser s) where-    pure f    = return f+    pure x    = P (\s ts-> Success (ts,s) x)     pf <*> px = do { f <- pf; x <- px; return (f x) } #if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610     p  <*  q  = p `discard` q
src/Text/ParserCombinators/Poly/Text.hs view
@@ -24,6 +24,7 @@ import qualified Data.Text.Lazy as T import Data.Text.Lazy (Text) import Control.Applicative+import qualified Control.Monad.Fail as Fail  -- | This @Parser@ datatype is a specialised parsing monad with error --   reporting.  Whereas the standard version can be used for arbitrary@@ -38,14 +39,17 @@     fmap f (P p) = P (fmap f . p)  instance Monad Parser where-    return x     = P (\ts-> Success ts x)-    fail e       = P (\ts-> Failure ts e)+    return       = pure+    fail         = Fail.fail     (P f) >>= g  = P (continue . f)       where         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 Fail.MonadFail Parser where+    fail e       = P (\ts-> Failure ts e)+ instance Commitment Parser where     commit (P p)         = P (Committed . squash . p)       where@@ -71,7 +75,7 @@             showErr (name,err) = name++":\n"++indent 2 err  instance Applicative Parser where-    pure f    = return f+    pure x    = P (\ts-> Success ts x)     pf <*> px = do { f <- pf; x <- px; return (f x) } #if defined(GLASGOW_HASKELL) && GLASGOW_HASKELL > 610     p  <*  q  = p `discard` q