Hello community,
here is the log from the commit of package ghc-parser-combinators for
openSUSE:Factory checked in at 2019-06-12 13:18:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-parser-combinators (Old)
and /work/SRC/openSUSE:Factory/.ghc-parser-combinators.new.4811 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-parser-combinators"
Wed Jun 12 13:18:40 2019 rev:6 rq:709201 version:1.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/ghc-parser-combinators/ghc-parser-combinators.changes
2019-05-17 23:42:52.169922495 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-parser-combinators.new.4811/ghc-parser-combinators.changes
2019-06-12 13:18:41.772568179 +0200
@@ -1,0 +2,9 @@
+Sun Jun 9 02:01:43 UTC 2019 - [email protected]
+
+- Update parser-combinators to version 1.1.0.
+ ## Parser combinators 1.1.0
+
+ * Added support for ternary operators; see `TernR` in
+ `Control.Monad.Combinators.Expr`.
+
+-------------------------------------------------------------------
Old:
----
parser-combinators-1.0.3.tar.gz
New:
----
parser-combinators-1.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-parser-combinators.spec ++++++
--- /var/tmp/diff_new_pack.aR45wi/_old 2019-06-12 13:18:42.412567887 +0200
+++ /var/tmp/diff_new_pack.aR45wi/_new 2019-06-12 13:18:42.412567887 +0200
@@ -18,7 +18,7 @@
%global pkg_name parser-combinators
Name: ghc-%{pkg_name}
-Version: 1.0.3
+Version: 1.1.0
Release: 0
Summary: Lightweight package providing commonly useful parser
combinators
License: BSD-3-Clause
++++++ parser-combinators-1.0.3.tar.gz -> parser-combinators-1.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/parser-combinators-1.0.3/CHANGELOG.md
new/parser-combinators-1.1.0/CHANGELOG.md
--- old/parser-combinators-1.0.3/CHANGELOG.md 2019-05-10 20:51:37.000000000
+0200
+++ new/parser-combinators-1.1.0/CHANGELOG.md 2019-06-08 23:57:40.000000000
+0200
@@ -1,3 +1,8 @@
+## Parser combinators 1.1.0
+
+* Added support for ternary operators; see `TernR` in
+ `Control.Monad.Combinators.Expr`.
+
## Parser combinators 1.0.3
* Dropped support for GHC 7.10.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/parser-combinators-1.0.3/Control/Monad/Combinators/Expr.hs
new/parser-combinators-1.1.0/Control/Monad/Combinators/Expr.hs
--- old/parser-combinators-1.0.3/Control/Monad/Combinators/Expr.hs
2019-05-10 20:51:37.000000000 +0200
+++ new/parser-combinators-1.1.0/Control/Monad/Combinators/Expr.hs
2019-06-08 23:57:40.000000000 +0200
@@ -30,6 +30,18 @@
| InfixR (m (a -> a -> a)) -- ^ Right-associative infix
| Prefix (m (a -> a)) -- ^ Prefix
| Postfix (m (a -> a)) -- ^ Postfix
+ | TernR (m (m (a -> a -> a -> a)))
+ -- ^ Right-associative ternary. Right-associative means that
+ -- @a ? b : d ? e : f@ parsed as
+ -- @a ? b : (d ? e : f)@ and not as @(a ? b : d) ? e : f@.
+ --
+ -- The outer monadic action parses the first separator (e.g. @?@) and
+ -- returns an action (of type @m (a -> a -> a -> a)@) that parses the
+ -- second separator (e.g. @:@).
+ --
+ -- Example usage:
+ --
+ -- >>> TernR ((If <$ char ':') <$ char '?')
-- | @'makeExprParser' term table@ builds an expression parser for terms
-- @term@ with operators from @table@, taking the associativity and
@@ -89,13 +101,14 @@
addPrecLevel :: MonadPlus m => m a -> [Operator m a] -> m a
addPrecLevel term ops =
- term' >>= \x -> choice [ras' x, las' x, nas' x, return x]
+ term' >>= \x -> choice [ras' x, las' x, nas' x, tern' x, return x]
where
- (ras, las, nas, prefix, postfix) = foldr splitOp ([],[],[],[],[]) ops
+ (ras, las, nas, prefix, postfix, tern) = foldr splitOp ([],[],[],[],[],[])
ops
term' = pTerm (choice prefix) term (choice postfix)
ras' = pInfixR (choice ras) term'
las' = pInfixL (choice las) term'
nas' = pInfixN (choice nas) term'
+ tern' = pTernR (choice tern) term'
{-# INLINEABLE addPrecLevel #-}
-- | @pTerm prefix term postfix@ parses a @term@ surrounded by optional
@@ -144,19 +157,33 @@
return $ f x y
{-# 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 sep1 p x = do
+ sep2 <- sep1
+ y <- p >>= \r -> pTernR sep1 p r `mplus` return r
+ f <- sep2
+ z <- p >>= \r -> pTernR sep1 p r `mplus` return r
+ return $ f x y z
+{-# INLINE pTernR #-}
+
type Batch m a =
( [m (a -> a -> a)]
, [m (a -> a -> a)]
, [m (a -> a -> a)]
, [m (a -> a)]
- , [m (a -> a)] )
+ , [m (a -> a)]
+ , [m (m (a -> a -> a -> a))]
+ )
-- | A helper to separate various operators (binary, unary, and according to
-- associativity) and return them in a tuple.
splitOp :: Operator m a -> Batch m a -> Batch m a
-splitOp (InfixR op) (r, l, n, pre, post) = (op:r, l, n, pre, post)
-splitOp (InfixL op) (r, l, n, pre, post) = (r, op:l, n, pre, post)
-splitOp (InfixN op) (r, l, n, pre, post) = (r, l, op:n, pre, post)
-splitOp (Prefix op) (r, l, n, pre, post) = (r, l, n, op:pre, post)
-splitOp (Postfix op) (r, l, n, pre, post) = (r, l, n, pre, op:post)
+splitOp (InfixR op) (r, l, n, pre, post, tern) = (op:r, l, n, pre, post, tern)
+splitOp (InfixL op) (r, l, n, pre, post, tern) = (r, op:l, n, pre, post, tern)
+splitOp (InfixN op) (r, l, n, pre, post, tern) = (r, l, op:n, pre, post, tern)
+splitOp (Prefix op) (r, l, n, pre, post, tern) = (r, l, n, op:pre, post, tern)
+splitOp (Postfix op) (r, l, n, pre, post, tern) = (r, l, n, pre, op:post, tern)
+splitOp (TernR op) (r, l, n, pre, post, tern) = (r, l, n, pre, post, op:tern)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/parser-combinators-1.0.3/parser-combinators.cabal
new/parser-combinators-1.1.0/parser-combinators.cabal
--- old/parser-combinators-1.0.3/parser-combinators.cabal 2019-05-10
20:51:37.000000000 +0200
+++ new/parser-combinators-1.1.0/parser-combinators.cabal 2019-06-08
23:57:40.000000000 +0200
@@ -1,5 +1,5 @@
name: parser-combinators
-version: 1.0.3
+version: 1.1.0
cabal-version: 1.18
tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.5
license: BSD3