Hello community, here is the log from the commit of package ghc-foldl for openSUSE:Factory checked in at 2018-08-20 16:20:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-foldl (Old) and /work/SRC/openSUSE:Factory/.ghc-foldl.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-foldl" Mon Aug 20 16:20:07 2018 rev:2 rq:630363 version:1.4.3 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-foldl/ghc-foldl.changes 2018-07-25 16:08:15.669346790 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-foldl.new/ghc-foldl.changes 2018-08-20 16:20:12.820889643 +0200 @@ -1,0 +2,9 @@ +Fri Aug 17 09:43:26 UTC 2018 - [email protected] + +- Update foldl to version 1.4.3. + 1.4.3 + + * Add `Control.Scanl.scanr` + * Increase upper bound on `mwc-random` + +------------------------------------------------------------------- Old: ---- foldl-1.4.2.tar.gz New: ---- foldl-1.4.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-foldl.spec ++++++ --- /var/tmp/diff_new_pack.o8rxcc/_old 2018-08-20 16:20:13.380890434 +0200 +++ /var/tmp/diff_new_pack.o8rxcc/_new 2018-08-20 16:20:13.380890434 +0200 @@ -18,7 +18,7 @@ %global pkg_name foldl Name: ghc-%{pkg_name} -Version: 1.4.2 +Version: 1.4.3 Release: 0 Summary: Composable, streaming, and efficient left folds License: BSD-3-Clause ++++++ foldl-1.4.2.tar.gz -> foldl-1.4.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/foldl-1.4.2/CHANGELOG.md new/foldl-1.4.3/CHANGELOG.md --- old/foldl-1.4.2/CHANGELOG.md 2018-07-04 04:52:30.000000000 +0200 +++ new/foldl-1.4.3/CHANGELOG.md 2018-08-04 17:04:07.000000000 +0200 @@ -1,3 +1,8 @@ +1.4.3 + +* Add `Control.Scanl.scanr` +* Increase upper bound on `mwc-random` + 1.4.2 * Add `Semigroupoid` instance for `Fold` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/foldl-1.4.2/README.md new/foldl-1.4.3/README.md --- old/foldl-1.4.2/README.md 2018-07-04 04:52:30.000000000 +0200 +++ new/foldl-1.4.3/README.md 2018-08-04 17:04:07.000000000 +0200 @@ -1,4 +1,4 @@ -# `foldl` v1.4.2 +# `foldl` v1.4.3 Use this `foldl` library when you want to compute multiple folds over a collection in one pass over the data without space leaks. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/foldl-1.4.2/foldl.cabal new/foldl-1.4.3/foldl.cabal --- old/foldl-1.4.2/foldl.cabal 2018-07-04 04:52:30.000000000 +0200 +++ new/foldl-1.4.3/foldl.cabal 2018-08-04 17:04:07.000000000 +0200 @@ -1,5 +1,5 @@ Name: foldl -Version: 1.4.2 +Version: 1.4.3 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3 @@ -26,7 +26,7 @@ Build-Depends: base >= 4.5 && < 5 , bytestring >= 0.9.2.1 && < 0.11, - mwc-random >= 0.13.1.0 && < 0.14, + mwc-random >= 0.13.1.0 && < 0.15, primitive < 0.7 , text >= 0.11.2.0 && < 1.3 , transformers >= 0.2.0.0 && < 0.6 , diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/foldl-1.4.2/src/Control/Scanl.hs new/foldl-1.4.3/src/Control/Scanl.hs --- old/foldl-1.4.2/src/Control/Scanl.hs 2018-07-04 04:52:30.000000000 +0200 +++ new/foldl-1.4.3/src/Control/Scanl.hs 2018-08-04 17:04:07.000000000 +0200 @@ -5,10 +5,11 @@ >>> import qualified Control.Scanl as SL - Use 'scan' to apply a 'Fold' to a list: + Use 'scan' to apply a 'Fold' to a list (or other 'Traversable' structures) from left to right, + and 'scanr' to do so from right to left. -} -{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} @@ -22,6 +23,7 @@ -- * Scanning , scan , scanM + , scanr , prescan , postscan @@ -54,7 +56,11 @@ import Data.Semigroup (Semigroup(..)) import Data.Traversable import Data.Tuple (swap) -import Prelude hiding ((.), id) +import Prelude hiding ((.), id, scanr) + +#if MIN_VERSION_base(4, 7, 0) +import Data.Coerce +#endif --import qualified Control.Foldl as L @@ -365,6 +371,12 @@ scan (Scan step begin) as = fst $ runState (traverse step as) begin {-# INLINE scan #-} +-- | Like 'scan' but start scanning from the right +scanr :: Traversable t => Scan a b -> t a -> t b +scanr (Scan step begin) as = + fst (runReverseState (traverse (ReverseState #. runState . step) as) begin) +{-# INLINE scanr #-} + -- | Like 'scan' but monadic scanM :: (Traversable t, Monad m) => ScanM m a b -> t a -> m (t b) scanM (ScanM step begin) as = fmap fst $ runStateT (traverse step as) =<< begin @@ -490,3 +502,50 @@ premapM :: Monad m => (a -> m b) -> ScanM m b r -> ScanM m a r premapM f (ScanM step begin) = ScanM (step <=< lift . f) begin {-# INLINABLE premapM #-} + + +-- Internal helpers (not exported) +newtype ReverseState s a = ReverseState + { runReverseState :: s -> (a, s) + } + +instance Functor (ReverseState s) where + fmap f (ReverseState m) = + ReverseState $ \s -> + let (v, s') = m s + in (f v, s') + {-# INLINE fmap #-} + +instance Applicative (ReverseState s) where + pure = ReverseState #. (,) + {-# INLINE pure #-} + + mf <*> mx = + ReverseState $ \s -> + let (f, s2) = runReverseState mf s1 + (x, s1) = runReverseState mx s + in (f x, s2) + {-# INLINE (<*>) #-} + +#if MIN_VERSION_base(4, 10, 0) + -- 'liftA2' was moved to the 'Applicative' class in base 4.10.0.0 + liftA2 f mx my = + ReverseState $ \s -> + let (x, s2) = runReverseState mx s1 + (y, s1) = runReverseState my s + in (f x y, s2) + {-# INLINE liftA2 #-} +#endif + + +#if MIN_VERSION_base(4, 7, 0) +-- | This is same as normal function composition, except slightly more efficient. The same trick is used in base <http://hackage.haskell.org/package/base-4.11.1.0/docs/src/Data.Functor.Utils.html#%23.> and lens <http://hackage.haskell.org/package/lens-4.17/docs/Control-Lens-Internal-Coerce.html#v:-35-..> +(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) +(#.) _ = coerce +#else +(#.) :: (b -> c) -> (a -> b) -> (a -> c) +(#.) = (.) +#endif + +infixr 9 #. +{-# INLINE (#.) #-}
