packages feed

foldl-incremental 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+6/−19 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Foldl.Incremental: scan :: Foldable f => Fold a b -> f a -> [b]

Files

foldl-incremental.cabal view
@@ -1,5 +1,5 @@ Name:                     foldl-incremental-Version:                  0.1.0.1+Version:                  0.1.0.2 Author:                   Tony Day Maintainer:               tonyday567@gmail.com License:                  MIT
src/Control/Foldl/Incremental.hs view
@@ -1,5 +1,7 @@ {-| This module provides incremental statistics folds based upon the foldl library +    To avoid clashes, Control.Foldl should be qualified.+ >>> import Control.Foldl.Incremental >>> import qualified Control.Foldl as L @@ -7,11 +9,11 @@      Statistics are based on exponential-weighting schemes which enable statistics to be calculated in a streaming one-pass manner.  The stream of moving averages with a `rate` of 0.9 is: ->>> scan (incMa 0.9) [1..10]+>>> L.scan (incMa 0.9) [1..10]  or if you just want the moving average at the end. ->>> fold (incMa 0.9) [1..10]+>>> L.fold (incMa 0.9) [1..10]  -} @@ -24,16 +26,10 @@   , incAbs   , incSq   , incStd-  -- * move to Foldl-  , scan-  -- * reexports-  , module Data.Foldable   ) where  import           Control.Applicative ((<$>), (<*>)) import           Control.Foldl (Fold(..))-import           Data.Foldable (Foldable(..))-import qualified Data.Foldable as F  -- | An Increment is the incremental state within an exponential moving average fold. data Increment = Increment@@ -99,12 +95,3 @@ incStd :: Double -> Fold Double Double incStd rate = (\s ss -> sqrt (ss - s**2)) <$> incMa rate <*> incSq rate {-# INLINABLE incStd #-}---- | Scan-scan :: (Foldable f) => Fold a b -> f a -> [b]-scan (Fold step begin done) as = F.foldr step' done' as begin'-  where-    step' x k z = k $! (step (head z) x:z)-    done' = map done . reverse-    begin' = [begin]-{-# INLINABLE scan #-}
test/bench.hs view
@@ -9,7 +9,7 @@  main :: IO () main = defaultMainWith Main.config (return ()) $-       BenchIncremental.component 0.1 [1..100000]+       BenchIncremental.component 0.1 [1..100000] [1..100000]  config :: Config config = defaultConfig  { cfgSamples = ljust 10 }