packages feed

uu-parsinglib 2.7.0.1 → 2.7.0.2

raw patch · 9 files changed

+55/−34 lines, 9 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Text.ParserCombinators.UU.Idioms: instance (Idiomatic (Str Char state loc) f g, IsLocationUpdatedBy loc Char, ListLike state Char) => Idiomatic (Str Char state loc) (a -> f) (P (Str Char state loc) a -> g)
- Text.ParserCombinators.UU.Idioms: instance Idiomatic (Str Char state loc) x (Ii -> P (Str Char state loc) x)
- Text.ParserCombinators.UU.Idioms: test :: Parser Int
+ Text.ParserCombinators.UU.Idioms: String' :: String -> String'
+ Text.ParserCombinators.UU.Idioms: data String'
+ Text.ParserCombinators.UU.Idioms: fromStr :: String' -> String
+ Text.ParserCombinators.UU.Idioms: instance Idiomatic st f g => Idiomatic st (a -> f) (P st a -> g)
+ Text.ParserCombinators.UU.Idioms: instance Idiomatic st x (Ii -> P st x)
- Text.ParserCombinators.UU.BasicInstances: pMunch :: (IsLocationUpdatedBy loc a, ListLike state a, Show a) => (a -> Bool) -> P (Str a state loc) [a]
+ Text.ParserCombinators.UU.BasicInstances: pMunch :: (Show a, IsLocationUpdatedBy loc a, ListLike state a) => (a -> Bool) -> P (Str a state loc) [a]
- Text.ParserCombinators.UU.BasicInstances: pRange :: (IsLocationUpdatedBy loc a, ListLike state a, Show a, Ord a) => (a, a) -> P (Str a state loc) a
+ Text.ParserCombinators.UU.BasicInstances: pRange :: (Ord a, Show a, IsLocationUpdatedBy loc a, ListLike state a) => (a, a) -> P (Str a state loc) a
- Text.ParserCombinators.UU.BasicInstances: pToken :: (IsLocationUpdatedBy loc a, ListLike state a, Show a, Eq a) => [a] -> P (Str a state loc) [a]
+ Text.ParserCombinators.UU.BasicInstances: pToken :: (Show a, Eq a, IsLocationUpdatedBy loc a, ListLike state a) => [a] -> P (Str a state loc) [a]
- Text.ParserCombinators.UU.Demo.Examples: pAnyToken :: [String] -> Parser String
+ Text.ParserCombinators.UU.Demo.Examples: pAnyToken :: (IsLocationUpdatedBy loc Char, ListLike state Char) => [String] -> P (Str Char state loc) String
- Text.ParserCombinators.UU.Demo.Examples: string :: String -> Parser String
+ Text.ParserCombinators.UU.Demo.Examples: string :: (IsLocationUpdatedBy loc Char, ListLike state Char) => String -> P (Str Char state loc) String
- Text.ParserCombinators.UU.Idioms: iI :: Idiomatic (Str Char state loc) (a -> a) g => g
+ Text.ParserCombinators.UU.Idioms: iI :: Idiomatic i (a -> a) g => g
- Text.ParserCombinators.UU.Utils: pAnySym :: String -> Parser Char
+ Text.ParserCombinators.UU.Utils: pAnySym :: (IsLocationUpdatedBy loc Char, ListLike state Char) => String -> P (Str Char state loc) Char
- Text.ParserCombinators.UU.Utils: pSymbol :: String -> Parser String
+ Text.ParserCombinators.UU.Utils: pSymbol :: (IsLocationUpdatedBy loc Char, ListLike state Char) => String -> P (Str Char state loc) String

Files

src/Text/ParserCombinators/UU.hs view
@@ -20,14 +20,10 @@ module Text.ParserCombinators.UU ( module Text.ParserCombinators.UU.Core                                  , module Text.ParserCombinators.UU.Derived                                  , module Text.ParserCombinators.UU.MergeAndPermute-                                 , module Control.Applicative-                                 , module Control.Monad                                  ) where import Text.ParserCombinators.UU.Core import Text.ParserCombinators.UU.Derived import Text.ParserCombinators.UU.MergeAndPermute-import Control.Applicative-import Control.Monad   
src/Text/ParserCombinators/UU/BasicInstances.hs view
@@ -14,8 +14,6 @@ --   positional information and the actual input that is being parsed. --   Unless you have very specific wishes the module can be used as such.  --   Since we make use of the "Data.ListLike" interface a wide variety of input structures can be handled.------   The main part of this module is made up from the various instances for the class `Provides`.  module Text.ParserCombinators.UU.BasicInstances( -- * Data Types@@ -39,7 +37,7 @@    pSym,    pToken,    pTokenCost,-   pMunch+   pMunch, ) where import Text.ParserCombinators.UU.Core import Data.Maybe@@ -135,7 +133,12 @@ instance  HasPosition (Str a s loc) loc where        getPos   (Str  inp      msgs pos ok    )        = pos +-- | the @String@ describes what is being inserted, the @a@ parameter the value which is to be inserted and the @cost@ the prices to be paid. data Insertion a = Insertion  String a Cost++-- | `pSatisfy`  describes and elementary parsing step. Its first parameter check whether the head element of the input can be recognised, +--    and the second parameter how to proceed in case an element recognised by this parser is absent, +--    and parsing may proceed by pretending such an element was present in the input anayway. pSatisfy :: forall loc state a .((Show a,  loc `IsLocationUpdatedBy` a, LL.ListLike state a) => (a -> Bool) -> (Insertion a) -> P (Str  a state loc) a) pSatisfy p  (Insertion msg  a cost) = pSymExt splitState (Succ (Zero Infinite)) Nothing   where  splitState :: forall r. ((a ->  (Str  a state loc)  -> Steps r) ->  (Str  a state loc) -> Steps r)@@ -152,18 +155,27 @@                               (Step 1 (k t (Str ts msgs (advance pos t) True)))                         else  Fail [msg] (ins: if del_ok then [del] else [])             )+-- | `pRangeInsert` recognises an element between a lower and an upper bound. Furthermore it can be specified what element +--   is to be inserted in case such an element is not at the head of the input. pRangeInsert :: (Ord a, Show a, IsLocationUpdatedBy loc a, LL.ListLike state a) => (a, a) -> Insertion a -> P (Str a state loc) a pRangeInsert (low, high)  = pSatisfy (\ t -> low <= t && t <= high)   +-- | `pRange` uses the information from the bounds to compute the `Insertion` information.+pRange ::  (Ord a, Show a, IsLocationUpdatedBy loc a, LL.ListLike state a) => (a, a) -> P (Str a state loc) a pRange lh@(low, high) = pRangeInsert lh (Insertion (show low ++ ".." ++ show high) low 5)  +-- | `pSymInsert` recognises a specific element. Furthermore it can be specified what element +--   is to be inserted in case such an element is not at the head of the input. pSymInsert  :: (Eq a,Show a, IsLocationUpdatedBy loc a, LL.ListLike state a) => a -> Insertion a -> P (Str a state loc) a pSymInsert  t  = pSatisfy (==t)  +-- | `pSym` recognises a specific element. Furthermore it can be specified what element. Information about `Insertion` is derived from the parameter.+--   is to be inserted in case such an element is not at the head of the input. pSym ::   (Eq a,Show a, IsLocationUpdatedBy loc a, LL.ListLike state a) => a ->  P (Str a state loc) a     pSym  t = pSymInsert t (Insertion (show t) t 5) +-- | `pMunchL` recognises the longest prefix of the input for which the passed predicate holds. The message parameer is used when tracing has been switched on.  pMunchL :: forall loc state a .((Show a,  loc `IsLocationUpdatedBy` a, LL.ListLike state a) => (a -> Bool) -> String -> P (Str  a state loc) [a]) pMunchL p msg = pSymExt splitState (Succ (Zero Infinite)) Nothing   where  splitState :: forall r. (([a] ->  (Str  a state loc)  -> Steps r) ->  (Str  a state loc) -> Steps r)@@ -177,8 +189,11 @@                            else show_munch ("Accepting munch: " ++ msg ++ " as emtty munch " ++ show pos ++ "\n") (k [] inp)                ) +-- | `pMunch` recognises the longest prefix of the input for which the passed predicate holds. The message parameer is used when tracing has been switched on. +pMunch :: forall loc state a .((Show a,  loc `IsLocationUpdatedBy` a, LL.ListLike state a) => (a -> Bool)  -> P (Str  a state loc) [a]) pMunch  p   = pMunchL p "" +-- | `pTokenCost` succeeds iis parameter is a prefix of the input.  pTokenCost :: forall loc state a .((Show a, Eq a,  loc `IsLocationUpdatedBy` a, LL.ListLike state a) => [a] -> Int -> P (Str  a state loc) [a]) pTokenCost as cost =    if null as then error "Module: BasicInstances, function: pTokenCost; call  with empty token"@@ -206,6 +221,7 @@                                      in  Fail [msg] (ins: if del_ok then [del] else [])                                             )+pToken ::  forall loc state a .((Show a, Eq a,  loc `IsLocationUpdatedBy` a, LL.ListLike state a) => [a] -> P (Str  a state loc) [a]) pToken     as   =   pTokenCost as 5  {-# INLINE show_tokens #-}
src/Text/ParserCombinators/UU/CHANGELOG.hs view
@@ -1,5 +1,9 @@ -- | This module just contains the CHANGELOG --+-- Version 2.7.0.2+--+--  * Some types were reformulated to compile correctly with ghc 6.12.3+-- -- Version 2.7.0.1 -- --  * Typos fixed in Haddock documentation
src/Text/ParserCombinators/UU/Core.hs view
@@ -41,7 +41,10 @@     getZeroP,     getOneP,     -- ** Evaluating the online result-    eval+    eval,+    -- ** Re-exported modules+    module Control.Applicative,+    module Control.Monad   ) where  import Control.Applicative
src/Text/ParserCombinators/UU/Demo/Examples.hs view
@@ -12,11 +12,12 @@  module Text.ParserCombinators.UU.Demo.Examples  where import Data.Char-import Text.ParserCombinators.UU +import Text.ParserCombinators.UU import Text.ParserCombinators.UU.Utils import Text.ParserCombinators.UU.BasicInstances import System.IO import GHC.IO.Handle.Types+import qualified Data.ListLike as LL  -- import Control.Monad @@ -246,7 +247,7 @@ simpleComment   =  string "<!--"  *>  pManyTill pAscii  (string "-->")  -string :: String -> Parser String+string ::(IsLocationUpdatedBy loc Char, LL.ListLike state Char) => String -> P (Str Char state loc)  String string = pToken  @@ -254,7 +255,7 @@ pConId  = (:) <$> pUpper <*> pList pIdChar pIdChar = pLower <|> pUpper <|> pDigit <|> pAnySym "='" -pAnyToken :: [String] -> Parser String+pAnyToken :: (IsLocationUpdatedBy loc Char, LL.ListLike state Char) => [String] -> P (Str Char state loc)  String  pAnyToken = pAny pToken  -- parsing two alternatives and returning both rsults
src/Text/ParserCombinators/UU/Derived.hs view
@@ -13,7 +13,6 @@  module Text.ParserCombinators.UU.Derived where import Text.ParserCombinators.UU.Core- import Control.Applicative  -- * Some aliases for oft occurring constructs
src/Text/ParserCombinators/UU/Idioms.hs view
@@ -6,6 +6,8 @@              FlexibleContexts,              CPP #-} +#define DEMO(p,i) demo "p" i p+ module Text.ParserCombinators.UU.Idioms where  import Text.ParserCombinators.UU@@ -15,41 +17,41 @@ import qualified Data.ListLike as LL import Control.Applicative  +data String' = String' {fromStr :: String}  -- | The  `Ii` is to be pronounced as @stop@ data Ii = Ii   -- | The function `iI` is to be pronounced as @start@-iI :: Idiomatic  (Str Char state loc) (a -> a) g => g+iI ::Idiomatic  i (a -> a) g => g iI = idiomatic (pure id) + class Idiomatic st f g  | g -> f st  where     idiomatic :: P st f -> g-instance  Idiomatic (Str Char state loc) x  (Ii -> P  (Str Char state loc) x) where+instance  Idiomatic st x  (Ii -> P st x) where     idiomatic ix Ii = ix-instance (Idiomatic  (Str Char state loc) f g, IsLocationUpdatedBy loc Char, LL.ListLike state Char) -       => Idiomatic  (Str Char state loc) (a -> f) (P  (Str Char state loc) a -> g) where+instance  Idiomatic st f g  => Idiomatic  st (a -> f) (P  st a -> g) where     idiomatic isf is = idiomatic (isf <*> is)+instance Idiomatic st f g => Idiomatic st ((a -> b) -> f)  ((a -> b) -> g) where+    idiomatic isf f = idiomatic (isf <*> (pure f))+ instance (Idiomatic  (Str Char state loc) f g, IsLocationUpdatedBy loc Char, LL.ListLike state Char)         => Idiomatic  (Str Char state loc) f (String -> g) where     idiomatic isf str = idiomatic (isf <* pToken str) instance  (Idiomatic (Str Char state loc) f g, IsLocationUpdatedBy loc Char, LL.ListLike state Char)        =>   Idiomatic (Str Char state loc) f (Char -> g) where     idiomatic isf c = idiomatic (isf <* pSym c)-instance Idiomatic st f g => Idiomatic st ((a -> b) -> f)  ((a -> b) -> g) where-    idiomatic isf f = idiomatic (isf <*> (pure f)) + -- | The idea of the Idiom concept is that  sequential composition operators can be inferred from the type  --   of the various operands ----- >>> run (iI (+) '(' pNatural "+"  pNatural ')' Ii) "(2+3"+-- >>> run (iI (+) '(' pNatural "plus"  pNatural ')' Ii) "(2 plus 3" --   Result: 5 --    Correcting steps:  --      Inserted  ')' at position LineColPos 0 4 4 expecting one of [')', Whitespace, '0'..'9'] ---test :: Parser Int-test = iI (+) '(' pNatural "+" pNatural ')' Ii -#define DEMO(p,i) demo "p" i p -show_demos =  demo "(iI (+) '(' pNatural \"+\" pNatural ')' Ii)::Parser Int" "(2+3)" ((iI (+) '(' pNatural "+" pNatural ')' Ii)::Parser Int)+show_demos =  demo "(iI (+) '(' pNatural \"plus\" pNatural ')' Ii)::Parser Int" "(2 plus 3)" ((iI (+) '(' pNatural "+" pNatural ')' Ii)::Parser Int)
src/Text/ParserCombinators/UU/Utils.hs view
@@ -81,9 +81,8 @@ import Data.List import Data.Time import Text.ParserCombinators.UU.Core-import Text.ParserCombinators.UU.BasicInstances -import Text.ParserCombinators.UU.Derived-import Control.Applicative+import Text.ParserCombinators.UU.BasicInstances+import Text.ParserCombinators.UU.Derived  import Text.Printf import qualified Data.ListLike  as LL @@ -119,7 +118,7 @@   where   digit2Int a = fromInteger $ toInteger $ ord a - ord '0' -pAnySym ::  String -> Parser Char+pAnySym ::  (IsLocationUpdatedBy loc Char, LL.ListLike state Char) => String -> P (Str Char state loc) Char pAnySym = pAny pSym  -- * Dealing with Whitespace@@ -141,7 +140,7 @@ pLBrace   = lexeme $ pSym '{' pRBrace   = lexeme $ pSym '}' -pSymbol :: String -> Parser String+pSymbol :: (IsLocationUpdatedBy loc Char, LL.ListLike state Char) => String -> P (Str Char state loc)  String pSymbol   = lexeme . pToken  -- * Parsers for Numbers
uu-parsinglib.cabal view
@@ -1,5 +1,5 @@ Name:                uu-parsinglib-Version:             2.7.0.1+Version:             2.7.0.2 Build-Type:          Simple License:             MIT Copyright:           S Doaitse Swierstra @@ -14,17 +14,18 @@ Description:         New version of the Utrecht University parser combinator library, which  provides online, error correction,                       annotation free, applicative style parser combinators. In addition to this we do  provide a monadic and idomatic interface.                      Parsers do analyse themselves to avoid commonly made errors. A recent addition was the combinator @`<||>`@ and -                     associates, which generalises merging and permuting parsers.+                     associates, which generalise merging and permuting parsers.                      .-                     This version is based on the module "Data.Listlike", and as a result a great variatey of input structures (@Strings@, @ByteStrings@, etc.) can be handled+                     This version is based on the module "Data.Listlike", and as a result a great variety of input structures (@Strings@, @ByteStrings@, etc.)+                     can be handled.                      .                      The modules "Text.ParserCombinators.UU.Demo.Examples", "Text.ParserCombinators.UU.Idioms" and "Text.ParserCombinators.UU.Demo.MergeAndpermute"                       contain a ready-made  @show_examples@  function,-                     which can be called (e.g. from @ghci@) to see e.g. the error correction at work. It contains extensive haddock documentation, so why not just take a look                           to see the correction process at work, and to get a feeling for how the various combinators can be used. +                     which can be called (e.g. from @ghci@) to see e.g. the error correction at work. It contains extensive haddock documentation, so why not just take a look                           to see the correction process at work, and to get a feeling for how the various combinators can be used?                       .-                     The file "Text.ParserCombinators.UU.CHANGELOG" contains a log of the most recent changes and additions+                     The file "Text.ParserCombinators.UU.CHANGELOG" contains a log of the most recent changes and additions.                      .-                     The file "Text.ParserCombinators.UU.README" contains some references to background information+                     The file "Text.ParserCombinators.UU.README" contains some references to background information.                      .                      We maintain a low frequency mailing for discussing the package. You can subscribe at:  <https://mail.cs.uu.nl/mailman/listinfo/parsing> Category:            Parsing Text