packages feed

foldl 1.4.11 → 1.4.12

raw patch · 3 files changed

+24/−10 lines, 3 filesdep +randomdep −mwc-randomdep ~hashabledep ~textdep ~transformersPVP ok

version bump matches the API change (PVP)

Dependencies added: random

Dependencies removed: mwc-random

Dependency ranges changed: hashable, text, transformers, vector

API changes (from Hackage documentation)

+ Control.Foldl: instance Data.Functor.Extend.Extend (Control.Foldl.Fold a)
+ Control.Foldl: instance GHC.Base.Monad m => Data.Functor.Extend.Extend (Control.Foldl.FoldM m a)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+1.4.12++* `Data.Functor.Extend.Extended` instances for `Fold` / `FoldM`+* Remove dependency on `mwc-random`+ 1.4.11  * Fix doctest failure when built against newer versions of the `hashable`
foldl.cabal view
@@ -1,5 +1,5 @@ Name: foldl-Version: 1.4.11+Version: 1.4.12 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3@@ -26,7 +26,7 @@     Build-Depends:         base         >= 4.8      && < 5   ,         bytestring   >= 0.9.2.1  && < 0.12,-        mwc-random   >= 0.13.1.0 && < 0.16,+        random       >= 1.2      && < 1.3 ,         primitive                   < 0.8 ,         text         >= 0.11.2.0 && < 1.3 ,         transformers >= 0.2.0.0  && < 0.6 ,
src/Control/Foldl.hs view
@@ -160,6 +160,7 @@ import Data.Monoid hiding ((<>)) import Data.Semigroup (Semigroup(..)) import Data.Semigroupoid (Semigroupoid)+import Data.Functor.Extend (Extend(..)) import Data.Profunctor import Data.Sequence ((|>)) import Data.Vector.Generic (Vector, Mutable)@@ -167,7 +168,7 @@ import Data.Hashable (Hashable) import Data.Traversable import Numeric.Natural (Natural)-import System.Random.MWC (GenIO, createSystemRandom, uniformR)+import System.Random (StdGen, newStdGen, uniformR) import Prelude hiding     ( head     , last@@ -260,6 +261,10 @@         in  Fold step begin done     {-# INLINE (<*>) #-} +instance Extend (Fold a) where+    duplicated = duplicate+    {-# INLINE duplicated #-}+ instance Semigroup b => Semigroup (Fold a b) where     (<>) = liftA2 (<>)     {-# INLINE (<>) #-}@@ -396,6 +401,10 @@         in  FoldM step begin done     {-# INLINE (<*>) #-} +instance Monad m => Extend (FoldM m a) where+    duplicated = duplicateM+    {-# INLINE duplicated #-}+ instance Functor m => Profunctor (FoldM m) where     rmap = fmap     lmap f (FoldM step begin done) = FoldM step' begin done@@ -798,14 +807,14 @@ random = FoldM step begin done   where     begin = do-        g <- createSystemRandom+        g <- newStdGen         return $! Pair3 g Nothing' (1 :: Int)      step (Pair3 g Nothing'  _) a = return $! Pair3 g (Just' a) 2     step (Pair3 g (Just' a) m) b = do-        n <- uniformR (1, m) g+        let (n, g') = uniformR (1, m) g         let c = if n == 1 then b else a-        return $! Pair3 g (Just' c) (m + 1)+        return $! Pair3 g' (Just' c) (m + 1)      done (Pair3 _ ma _) = return (lazy ma) {-# INLINABLE random #-}@@ -816,7 +825,7 @@     { _size      ::                !VectorState     , _reservoir ::                !(Mutable v RealWorld a)     , _position  :: {-# UNPACK #-} !Int-    , _gen       :: {-# UNPACK #-} !GenIO+    , _gen       :: {-# UNPACK #-} !StdGen     }  -- | Pick several random elements, using reservoir sampling@@ -832,15 +841,15 @@         let s  = if n <= m' then Complete else Incomplete m'         return $! RandomNState s mv (i + 1) g     step (RandomNState  Complete      mv i g) a = do-        r <- uniformR (0, i - 1) g+        let (r, g') = uniformR (0, i - 1) g         if r < n             then M.unsafeWrite mv r a             else return ()-        return (RandomNState Complete mv (i + 1) g)+        return (RandomNState Complete mv (i + 1) g')      begin = do         mv  <- M.new n-        gen <- createSystemRandom+        gen <- newStdGen         let s = if n <= 0 then Complete else Incomplete 0         return (RandomNState s mv 1 gen)