Copyright | (c) 2011 Bryan O'Sullivan 2016 National ICT Australia 2018 CSIRO |
---|---|
License | BSD3 |
Maintainer | Alex.Mason@data61.csiro.au |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- range :: Fold Double Double
- sum' :: Fold Double Double
- histogram :: Ord a => Fold a (Map a Int)
- histogram' :: (Hashable a, Eq a) => Fold a (HashMap a Int)
- ordersOfMagnitude :: Fold Double (Map Double Int)
- mean :: Fold Double Double
- welfordMean :: Fold Double Double
- meanWeighted :: Fold (Double, Double) Double
- harmonicMean :: Fold Double Double
- geometricMean :: Fold Double Double
- centralMoment :: Int -> Double -> Fold Double Double
- centralMoments :: Int -> Int -> Double -> Fold Double (Double, Double)
- centralMoments' :: Int -> Int -> Double -> Fold Double (Double, Double)
- skewness :: Double -> Fold Double Double
- kurtosis :: Double -> Fold Double Double
- variance :: Double -> Fold Double Double
- varianceUnbiased :: Double -> Fold Double Double
- stdDev :: Double -> Fold Double Double
- varianceWeighted :: Double -> Fold (Double, Double) Double
- fastVariance :: Fold Double Double
- fastVarianceUnbiased :: Fold Double Double
- fastStdDev :: Fold Double Double
- fastLMVSK :: Fold Double LMVSK
- fastLMVSKu :: Fold Double LMVSK
- data LMVSK = LMVSK {
- lmvskCount :: !Int
- lmvskMean :: !Double
- lmvskVariance :: !Double
- lmvskSkewness :: !Double
- lmvskKurtosis :: !Double
- data LMVSKState
- foldLMVSKState :: Fold Double LMVSKState
- getLMVSK :: LMVSKState -> LMVSK
- getLMVSKu :: LMVSKState -> LMVSK
- fastLinearReg :: Fold (Double, Double) LinRegResult
- foldLinRegState :: Fold (Double, Double) LinRegState
- getLinRegResult :: LinRegState -> LinRegResult
- data LinRegResult = LinRegResult {
- lrrSlope :: !Double
- lrrIntercept :: !Double
- lrrCorrelation :: !Double
- lrrXStats :: !LMVSK
- lrrYStats :: !LMVSK
- data LinRegState
- lrrCount :: LinRegResult -> Int
- correlation :: (Double, Double) -> (Double, Double) -> Fold (Double, Double) Double
- class Foldable (t :: * -> *)
- data RealWorld
- groupBy :: Ord g => (a -> g) -> Fold a r -> Fold a (Map g r)
- filtered :: Monoid m => (a -> Bool) -> (a -> m) -> a -> m
- folded :: (Contravariant f, Applicative f, Foldable t) => (a -> f a) -> t a -> f (t a)
- foldOverM :: Monad m => HandlerM m s a -> FoldM m a b -> s -> m b
- handlesM :: HandlerM m a b -> FoldM m b r -> FoldM m a r
- foldOver :: Handler s a -> Fold a b -> s -> b
- handles :: Handler a b -> Fold b r -> Fold a r
- prefilterM :: Monad m => (a -> m Bool) -> FoldM m a r -> FoldM m a r
- prefilter :: (a -> Bool) -> Fold a r -> Fold a r
- premapM :: Monad m => (a -> m b) -> FoldM m b r -> FoldM m a r
- premap :: (a -> b) -> Fold b r -> Fold a r
- _Fold1 :: (a -> a -> a) -> Fold a (Maybe a)
- duplicateM :: Applicative m => FoldM m a b -> FoldM m a (FoldM m a b)
- hoists :: (forall x. m x -> n x) -> FoldM m a b -> FoldM n a b
- simplify :: FoldM Identity a b -> Fold a b
- generalize :: Monad m => Fold a b -> FoldM m a b
- impurely_ :: Monad m => (forall x. (x -> a -> m x) -> m x -> m x) -> FoldM m a b -> m b
- impurely :: (forall x. (x -> a -> m x) -> m x -> (x -> m b) -> r) -> FoldM m a b -> r
- purely_ :: (forall x. (x -> a -> x) -> x -> x) -> Fold a b -> b
- purely :: (forall x. (x -> a -> x) -> x -> (x -> b) -> r) -> Fold a b -> r
- vectorM :: (PrimMonad m, Vector v a) => FoldM m a (v a)
- vector :: Vector v a => Fold a (v a)
- hashMap :: (Eq a, Hashable a) => Fold (a, b) (HashMap a b)
- map :: Ord a => Fold (a, b) (Map a b)
- hashSet :: (Eq a, Hashable a) => Fold a (HashSet a)
- set :: Ord a => Fold a (Set a)
- eqNub :: Eq a => Fold a [a]
- nub :: Ord a => Fold a [a]
- revList :: Fold a [a]
- list :: Fold a [a]
- genericIndex :: Integral i => i -> Fold a (Maybe a)
- genericLength :: Num b => Fold a b
- sink :: (Monoid w, Monad m) => (a -> m w) -> FoldM m a w
- mapM_ :: Monad m => (a -> m ()) -> FoldM m a ()
- randomN :: Vector v a => Int -> FoldM IO a (Maybe (v a))
- random :: FoldM IO a (Maybe a)
- lookup :: Eq a => a -> Fold (a, b) (Maybe b)
- findIndex :: (a -> Bool) -> Fold a (Maybe Int)
- elemIndex :: Eq a => a -> Fold a (Maybe Int)
- index :: Int -> Fold a (Maybe a)
- find :: (a -> Bool) -> Fold a (Maybe a)
- notElem :: Eq a => a -> Fold a Bool
- elem :: Eq a => a -> Fold a Bool
- minimumBy :: (a -> a -> Ordering) -> Fold a (Maybe a)
- minimum :: Ord a => Fold a (Maybe a)
- maximumBy :: (a -> a -> Ordering) -> Fold a (Maybe a)
- maximum :: Ord a => Fold a (Maybe a)
- std :: Floating a => Fold a a
- product :: Num a => Fold a a
- sum :: Num a => Fold a a
- any :: (a -> Bool) -> Fold a Bool
- all :: (a -> Bool) -> Fold a Bool
- or :: Fold Bool Bool
- and :: Fold Bool Bool
- length :: Fold a Int
- null :: Fold a Bool
- lastN :: Int -> Fold a [a]
- lastDef :: a -> Fold a a
- last :: Fold a (Maybe a)
- head :: Fold a (Maybe a)
- foldMap :: Monoid w => (a -> w) -> (w -> b) -> Fold a b
- mconcat :: Monoid a => Fold a a
- postscan :: Traversable t => Fold a b -> t a -> t b
- prescan :: Traversable t => Fold a b -> t a -> t b
- scan :: Fold a b -> [a] -> [b]
- foldM :: (Foldable f, Monad m) => FoldM m a b -> f a -> m b
- fold :: Foldable f => Fold a b -> f a -> b
- data Fold a b where
- data FoldM (m :: * -> *) a b where
- type Handler a b = forall x. (b -> Const (Dual (Endo x)) b) -> a -> Const (Dual (Endo x)) a
- newtype EndoM (m :: * -> *) a = EndoM {
- appEndoM :: a -> m a
- type HandlerM (m :: * -> *) a b = forall x. (b -> Const (Dual (EndoM m x)) b) -> a -> Const (Dual (EndoM m x)) a
- class MVector (Mutable v) a => Vector (v :: * -> *) a
- type family Mutable (v :: * -> *) :: * -> * -> *
- class Monad m => PrimMonad (m :: * -> *)
Introduction
Statistical functions from the
Statistics.Sample
module of the
statistics package by
Bryan O'Sullivan, implemented as Fold
s from the
foldl package.
This allows many statistics to be computed concurrently with at most
two passes over the data, usually by computing the mean
first, and
passing it to further Fold
s.
range :: Fold Double Double Source #
The difference between the largest and smallest elements of a sample.
sum' :: Fold Double Double Source #
A numerically stable sum using Kahan-Babuška-Neumaier summation from Numeric.Sum
histogram :: Ord a => Fold a (Map a Int) Source #
Create a histogram of each value of type a. Useful for folding over categorical values, for example, a CSV where you have a data type for a selection of categories.
It should not be used for continuous values which would lead to a high number
of keys. One way to avoid this is to use the Profunctor
instance for Fold
to break your values into categories. For an example of doing this, see
ordersOfMagnitude
.
histogram' :: (Hashable a, Eq a) => Fold a (HashMap a Int) Source #
Like histogram
, but for use when hashmaps would be more efficient for the
particular type a
.
ordersOfMagnitude :: Fold Double (Map Double Int) Source #
Provides a histogram of the orders of magnitude of the values in a series.
Negative values are placed in the 0.0
category due to the behaviour of
logBase
. it may be useful to use lmap abs
on this Fold to get a histogram
of the absolute magnitudes.
Statistics of location
mean :: Fold Double Double Source #
Arithmetic mean. This uses Kahan-Babuška-Neumaier
summation, so is more accurate than welfordMean
unless the input
values are very large.
Since foldl-1.2.2, Foldl
exports a mean
function, so you will
have to hide one.
welfordMean :: Fold Double Double Source #
Arithmetic mean. This uses Welford's algorithm to provide numerical stability, using a single pass over the sample data.
Compared to mean
, this loses a surprising amount of precision
unless the inputs are very large.
meanWeighted :: Fold (Double, Double) Double Source #
Arithmetic mean for weighted sample. It uses a single-pass
algorithm analogous to the one used by welfordMean
.
geometricMean :: Fold Double Double Source #
Geometric mean of a sample containing no negative values.
Statistics of dispersion
The variance—and hence the standard deviation—of a sample of fewer than two elements are both defined to be zero.
Many of these Folds take the mean as an argument for constructing the variance, and as such require two passes over the data.
Functions over central moments
centralMoment :: Int -> Double -> Fold Double Double Source #
Compute the kth central moment of a sample. The central moment is also known as the moment about the mean.
This function requires the mean of the data to compute the central moment.
For samples containing many values very close to the mean, this function is subject to inaccuracy due to catastrophic cancellation.
centralMoments :: Int -> Int -> Double -> Fold Double (Double, Double) Source #
Compute the kth and jth central moments of a sample.
This fold requires the mean of the data to be known.
For samples containing many values very close to the mean, this function is subject to inaccuracy due to catastrophic cancellation.
centralMoments' :: Int -> Int -> Double -> Fold Double (Double, Double) Source #
Compute the kth and jth central moments of a sample.
This fold requires the mean of the data to be known.
This variation of centralMoments
uses Kahan-Babuška-Neumaier
summation to attempt to improve the accuracy of results, which may
make computation slower.
skewness :: Double -> Fold Double Double Source #
Compute the skewness of a sample. This is a measure of the asymmetry of its distribution.
A sample with negative skew is said to be left-skewed. Most of its mass is on the right of the distribution, with the tail on the left.
skewness $ U.to [1,100,101,102,103] ==> -1.497681449918257
A sample with positive skew is said to be right-skewed.
skewness $ U.to [1,2,3,4,100] ==> 1.4975367033335198
A sample's skewness is not defined if its variance
is zero.
This fold requires the mean of the data to be known.
For samples containing many values very close to the mean, this function is subject to inaccuracy due to catastrophic cancellation.
kurtosis :: Double -> Fold Double Double Source #
Compute the excess kurtosis of a sample. This is a measure of the "peakedness" of its distribution. A high kurtosis indicates that more of the sample's variance is due to infrequent severe deviations, rather than more frequent modest deviations.
A sample's excess kurtosis is not defined if its variance
is
zero.
This fold requires the mean of the data to be known.
For samples containing many values very close to the mean, this function is subject to inaccuracy due to catastrophic cancellation.
Functions requiring the mean to be known (numerically robust)
These functions use the compensated summation algorithm of Chan et al. for numerical robustness, but require two passes over the sample data as a result.
variance :: Double -> Fold Double Double Source #
Maximum likelihood estimate of a sample's variance. Also known as the population variance, where the denominator is n.
varianceUnbiased :: Double -> Fold Double Double Source #
Unbiased estimate of a sample's variance. Also known as the sample variance, where the denominator is n-1.
stdDev :: Double -> Fold Double Double Source #
Standard deviation. This is simply the square root of the unbiased estimate of the variance.
varianceWeighted :: Double -> Fold (Double, Double) Double Source #
Weighted variance. This is biased estimation. Requires the weighted mean of the input data.
Single-pass functions (faster, less safe)
The functions prefixed with the name fast
below perform a single
pass over the sample data using Knuth's algorithm. They usually
work well, but see below for caveats. These functions are subject
to fusion and do not require the mean to be passed.
Note: in cases where most sample data is close to the sample's mean, Knuth's algorithm gives inaccurate results due to catastrophic cancellation.
fastVarianceUnbiased :: Fold Double Double Source #
Maximum likelihood estimate of a sample's variance.
fastStdDev :: Fold Double Double Source #
Standard deviation. This is simply the square root of the maximum likelihood estimate of the variance.
fastLMVSK :: Fold Double LMVSK Source #
Efficiently compute the length, mean, variance, skewness and kurtosis with a single pass.
Since: 0.1.1.0
fastLMVSKu :: Fold Double LMVSK Source #
Efficiently compute the length, mean, unbiased variance, skewness and kurtosis with a single pass.
Since: 0.1.3.0
When returned by fastLMVSK
, contains the count, mean,
variance, skewness and kurtosis of a series of samples.
Since: 0.1.1.0
LMVSK | |
|
data LMVSKState Source #
Instances
Semigroup LMVSKState Source # | |
Defined in Control.Foldl.Statistics (<>) :: LMVSKState -> LMVSKState -> LMVSKState # sconcat :: NonEmpty LMVSKState -> LMVSKState # stimes :: Integral b => b -> LMVSKState -> LMVSKState # | |
Monoid LMVSKState Source # | |
Defined in Control.Foldl.Statistics mempty :: LMVSKState # mappend :: LMVSKState -> LMVSKState -> LMVSKState # mconcat :: [LMVSKState] -> LMVSKState # |
foldLMVSKState :: Fold Double LMVSKState Source #
Performs the heavy lifting of fastLMVSK. This is exposed
because the internal LMVSKState
is monoidal, allowing you
to run these statistics in parallel over datasets which are
split and then combine the results.
Since: 0.1.2.0
getLMVSK :: LMVSKState -> LMVSK Source #
Returns the stats which have been computed in a LMVSKState.
Since: 0.1.2.0
getLMVSKu :: LMVSKState -> LMVSK Source #
Returns the stats which have been computed in a LMVSKState, with the unbiased variance.
Since: 0.1.2.0
Linear Regression
fastLinearReg :: Fold (Double, Double) LinRegResult Source #
Computes the slope, (Y) intercept and correlation of (x,y)
pairs, as well as the LMVSK
stats for both the x and y series.
>>>
F.fold fastLinearReg $ map (\x -> (x,3*x+7)) [1..100]
LinRegResult {lrrSlope = 3.0 , lrrIntercept = 7.0 , lrrCorrelation = 100.0 , lrrXStats = LMVSK {lmvskCount = 100 , lmvskMean = 50.5 , lmvskVariance = 833.25 , lmvskSkewness = 0.0 , lmvskKurtosis = -1.2002400240024003} , lrrYStats = LMVSK {lmvskCount = 100 , lmvskMean = 158.5 , lmvskVariance = 7499.25 , lmvskSkewness = 0.0 , lmvskKurtosis = -1.2002400240024003} }
>>>
F.fold fastLinearReg $ map (\x -> (x,0.005*x*x+3*x+7)) [1..100]
LinRegResult {lrrSlope = 3.5049999999999994 , lrrIntercept = -1.5849999999999795 , lrrCorrelation = 99.93226275740273 , lrrXStats = LMVSK {lmvskCount = 100 , lmvskMean = 50.5 , lmvskVariance = 833.25 , lmvskSkewness = 0.0 , lmvskKurtosis = -1.2002400240024003} , lrrYStats = LMVSK {lmvskCount = 100 , lmvskMean = 175.4175 , lmvskVariance = 10250.37902625 , lmvskSkewness = 9.862971188165422e-2 , lmvskKurtosis = -1.1923628437011482} }
Since: 0.1.1.0
foldLinRegState :: Fold (Double, Double) LinRegState Source #
Performs the heavy lifting for fastLinReg
. Exposed because LinRegState
is a Monoid
, allowing statistics to be computed on datasets in parallel
and combined afterwards.
Since: 0.1.4.0
getLinRegResult :: LinRegState -> LinRegResult Source #
Produces the slope, Y intercept, correlation and LMVSK stats from a
LinRegState
.
Since: 0.1.4.0
data LinRegResult Source #
When returned by fastLinearReg
, contains the count,
slope, intercept and correlation of combining (x,y)
pairs.
Since: 0.1.1.0
LinRegResult | |
|
Instances
Eq LinRegResult Source # | |
Defined in Control.Foldl.Statistics (==) :: LinRegResult -> LinRegResult -> Bool # (/=) :: LinRegResult -> LinRegResult -> Bool # | |
Show LinRegResult Source # | |
Defined in Control.Foldl.Statistics showsPrec :: Int -> LinRegResult -> ShowS # show :: LinRegResult -> String # showList :: [LinRegResult] -> ShowS # |
data LinRegState Source #
The Monoidal state used to compute linear regression, see fastLinearReg
.
Since: 0.1.4.0
Instances
Semigroup LinRegState Source # | |
Defined in Control.Foldl.Statistics (<>) :: LinRegState -> LinRegState -> LinRegState # sconcat :: NonEmpty LinRegState -> LinRegState # stimes :: Integral b => b -> LinRegState -> LinRegState # | |
Monoid LinRegState Source # | |
Defined in Control.Foldl.Statistics mempty :: LinRegState # mappend :: LinRegState -> LinRegState -> LinRegState # mconcat :: [LinRegState] -> LinRegState # |
lrrCount :: LinRegResult -> Int Source #
The number of elements which make up this LinRegResult
Since: 0.1.4.1
correlation :: (Double, Double) -> (Double, Double) -> Fold (Double, Double) Double Source #
Given the mean and standard deviation of two distributions, computes
the correlation between them, given the means and standard deviation
of the x
and y
series. The results may be more accurate than those
returned by fastLinearReg
References
- Chan, T. F.; Golub, G.H.; LeVeque, R.J. (1979) Updating formulae and a pairwise algorithm for computing sample variances. Technical Report STAN-CS-79-773, Department of Computer Science, Stanford University. ftp://reports.stanford.edu/pub/cstr/reports/cs/tr/79/773/CS-TR-79-773.pdf
- Knuth, D.E. (1998) The art of computer programming, volume 2: seminumerical algorithms, 3rd ed., p. 232.
- Welford, B.P. (1962) Note on a method for calculating corrected sums of squares and products. Technometrics 4(3):419–420. http://www.jstor.org/stable/1266577
- West, D.H.D. (1979) Updating mean and variance estimates: an improved method. Communications of the ACM 22(9):532–535. http://doi.acm.org/10.1145/359146.359153
- John D. Cook. Computing skewness and kurtosis in one pass http://www.johndcook.com/blog/skewness_kurtosis/
class Foldable (t :: * -> *) #
Data structures that can be folded.
For example, given a data type
data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
a suitable instance would be
instance Foldable Tree where foldMap f Empty = mempty foldMap f (Leaf x) = f x foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
This is suitable even for abstract types, as the monoid is assumed
to satisfy the monoid laws. Alternatively, one could define foldr
:
instance Foldable Tree where foldr f z Empty = z foldr f z (Leaf x) = f x z foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
Foldable
instances are expected to satisfy the following laws:
foldr f z t = appEndo (foldMap (Endo . f) t ) z
foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
fold = foldMap id
length = getSum . foldMap (Sum . const 1)
sum
, product
, maximum
, and minimum
should all be essentially
equivalent to foldMap
forms, such as
sum = getSum . foldMap Sum
but may be less defined.
If the type is also a Functor
instance, it should satisfy
foldMap f = fold . fmap f
which implies that
foldMap f . fmap g = foldMap (f . g)
Instances
Foldable [] | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => [m] -> m # foldMap :: Monoid m => (a -> m) -> [a] -> m # foldr :: (a -> b -> b) -> b -> [a] -> b # foldr' :: (a -> b -> b) -> b -> [a] -> b # foldl :: (b -> a -> b) -> b -> [a] -> b # foldl' :: (b -> a -> b) -> b -> [a] -> b # foldr1 :: (a -> a -> a) -> [a] -> a # foldl1 :: (a -> a -> a) -> [a] -> a # elem :: Eq a => a -> [a] -> Bool # maximum :: Ord a => [a] -> a # | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Foldable Par1 | |
Defined in Data.Foldable fold :: Monoid m => Par1 m -> m # foldMap :: Monoid m => (a -> m) -> Par1 a -> m # foldr :: (a -> b -> b) -> b -> Par1 a -> b # foldr' :: (a -> b -> b) -> b -> Par1 a -> b # foldl :: (b -> a -> b) -> b -> Par1 a -> b # foldl' :: (b -> a -> b) -> b -> Par1 a -> b # foldr1 :: (a -> a -> a) -> Par1 a -> a # foldl1 :: (a -> a -> a) -> Par1 a -> a # elem :: Eq a => a -> Par1 a -> Bool # maximum :: Ord a => Par1 a -> a # | |
Foldable Complex | |
Defined in Data.Complex fold :: Monoid m => Complex m -> m # foldMap :: Monoid m => (a -> m) -> Complex a -> m # foldr :: (a -> b -> b) -> b -> Complex a -> b # foldr' :: (a -> b -> b) -> b -> Complex a -> b # foldl :: (b -> a -> b) -> b -> Complex a -> b # foldl' :: (b -> a -> b) -> b -> Complex a -> b # foldr1 :: (a -> a -> a) -> Complex a -> a # foldl1 :: (a -> a -> a) -> Complex a -> a # elem :: Eq a => a -> Complex a -> Bool # maximum :: Ord a => Complex a -> a # minimum :: Ord a => Complex a -> a # | |
Foldable Min | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Min m -> m # foldMap :: Monoid m => (a -> m) -> Min a -> m # foldr :: (a -> b -> b) -> b -> Min a -> b # foldr' :: (a -> b -> b) -> b -> Min a -> b # foldl :: (b -> a -> b) -> b -> Min a -> b # foldl' :: (b -> a -> b) -> b -> Min a -> b # foldr1 :: (a -> a -> a) -> Min a -> a # foldl1 :: (a -> a -> a) -> Min a -> a # elem :: Eq a => a -> Min a -> Bool # maximum :: Ord a => Min a -> a # | |
Foldable Max | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Max m -> m # foldMap :: Monoid m => (a -> m) -> Max a -> m # foldr :: (a -> b -> b) -> b -> Max a -> b # foldr' :: (a -> b -> b) -> b -> Max a -> b # foldl :: (b -> a -> b) -> b -> Max a -> b # foldl' :: (b -> a -> b) -> b -> Max a -> b # foldr1 :: (a -> a -> a) -> Max a -> a # foldl1 :: (a -> a -> a) -> Max a -> a # elem :: Eq a => a -> Max a -> Bool # maximum :: Ord a => Max a -> a # | |
Foldable First | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Foldable Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Foldable Option | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Option m -> m # foldMap :: Monoid m => (a -> m) -> Option a -> m # foldr :: (a -> b -> b) -> b -> Option a -> b # foldr' :: (a -> b -> b) -> b -> Option a -> b # foldl :: (b -> a -> b) -> b -> Option a -> b # foldl' :: (b -> a -> b) -> b -> Option a -> b # foldr1 :: (a -> a -> a) -> Option a -> a # foldl1 :: (a -> a -> a) -> Option a -> a # elem :: Eq a => a -> Option a -> Bool # maximum :: Ord a => Option a -> a # minimum :: Ord a => Option a -> a # | |
Foldable Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity fold :: Monoid m => Identity m -> m # foldMap :: Monoid m => (a -> m) -> Identity a -> m # foldr :: (a -> b -> b) -> b -> Identity a -> b # foldr' :: (a -> b -> b) -> b -> Identity a -> b # foldl :: (b -> a -> b) -> b -> Identity a -> b # foldl' :: (b -> a -> b) -> b -> Identity a -> b # foldr1 :: (a -> a -> a) -> Identity a -> a # foldl1 :: (a -> a -> a) -> Identity a -> a # elem :: Eq a => a -> Identity a -> Bool # maximum :: Ord a => Identity a -> a # minimum :: Ord a => Identity a -> a # | |
Foldable First | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Foldable Last | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # | |
Foldable Sum | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Sum m -> m # foldMap :: Monoid m => (a -> m) -> Sum a -> m # foldr :: (a -> b -> b) -> b -> Sum a -> b # foldr' :: (a -> b -> b) -> b -> Sum a -> b # foldl :: (b -> a -> b) -> b -> Sum a -> b # foldl' :: (b -> a -> b) -> b -> Sum a -> b # foldr1 :: (a -> a -> a) -> Sum a -> a # foldl1 :: (a -> a -> a) -> Sum a -> a # elem :: Eq a => a -> Sum a -> Bool # maximum :: Ord a => Sum a -> a # | |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Product m -> m # foldMap :: Monoid m => (a -> m) -> Product a -> m # foldr :: (a -> b -> b) -> b -> Product a -> b # foldr' :: (a -> b -> b) -> b -> Product a -> b # foldl :: (b -> a -> b) -> b -> Product a -> b # foldl' :: (b -> a -> b) -> b -> Product a -> b # foldr1 :: (a -> a -> a) -> Product a -> a # foldl1 :: (a -> a -> a) -> Product a -> a # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # | |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => NonEmpty m -> m # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b # foldr1 :: (a -> a -> a) -> NonEmpty a -> a # foldl1 :: (a -> a -> a) -> NonEmpty a -> a # elem :: Eq a => a -> NonEmpty a -> Bool # maximum :: Ord a => NonEmpty a -> a # minimum :: Ord a => NonEmpty a -> a # | |
Foldable IntMap | |
Defined in Data.IntMap.Internal fold :: Monoid m => IntMap m -> m # foldMap :: Monoid m => (a -> m) -> IntMap a -> m # foldr :: (a -> b -> b) -> b -> IntMap a -> b # foldr' :: (a -> b -> b) -> b -> IntMap a -> b # foldl :: (b -> a -> b) -> b -> IntMap a -> b # foldl' :: (b -> a -> b) -> b -> IntMap a -> b # foldr1 :: (a -> a -> a) -> IntMap a -> a # foldl1 :: (a -> a -> a) -> IntMap a -> a # elem :: Eq a => a -> IntMap a -> Bool # maximum :: Ord a => IntMap a -> a # minimum :: Ord a => IntMap a -> a # | |
Foldable Tree | |
Defined in Data.Tree fold :: Monoid m => Tree m -> m # foldMap :: Monoid m => (a -> m) -> Tree a -> m # foldr :: (a -> b -> b) -> b -> Tree a -> b # foldr' :: (a -> b -> b) -> b -> Tree a -> b # foldl :: (b -> a -> b) -> b -> Tree a -> b # foldl' :: (b -> a -> b) -> b -> Tree a -> b # foldr1 :: (a -> a -> a) -> Tree a -> a # foldl1 :: (a -> a -> a) -> Tree a -> a # elem :: Eq a => a -> Tree a -> Bool # maximum :: Ord a => Tree a -> a # | |
Foldable Seq | |
Defined in Data.Sequence.Internal fold :: Monoid m => Seq m -> m # foldMap :: Monoid m => (a -> m) -> Seq a -> m # foldr :: (a -> b -> b) -> b -> Seq a -> b # foldr' :: (a -> b -> b) -> b -> Seq a -> b # foldl :: (b -> a -> b) -> b -> Seq a -> b # foldl' :: (b -> a -> b) -> b -> Seq a -> b # foldr1 :: (a -> a -> a) -> Seq a -> a # foldl1 :: (a -> a -> a) -> Seq a -> a # elem :: Eq a => a -> Seq a -> Bool # maximum :: Ord a => Seq a -> a # | |
Foldable FingerTree | |
Defined in Data.Sequence.Internal fold :: Monoid m => FingerTree m -> m # foldMap :: Monoid m => (a -> m) -> FingerTree a -> m # foldr :: (a -> b -> b) -> b -> FingerTree a -> b # foldr' :: (a -> b -> b) -> b -> FingerTree a -> b # foldl :: (b -> a -> b) -> b -> FingerTree a -> b # foldl' :: (b -> a -> b) -> b -> FingerTree a -> b # foldr1 :: (a -> a -> a) -> FingerTree a -> a # foldl1 :: (a -> a -> a) -> FingerTree a -> a # toList :: FingerTree a -> [a] # null :: FingerTree a -> Bool # length :: FingerTree a -> Int # elem :: Eq a => a -> FingerTree a -> Bool # maximum :: Ord a => FingerTree a -> a # minimum :: Ord a => FingerTree a -> a # sum :: Num a => FingerTree a -> a # product :: Num a => FingerTree a -> a # | |
Foldable Digit | |
Defined in Data.Sequence.Internal fold :: Monoid m => Digit m -> m # foldMap :: Monoid m => (a -> m) -> Digit a -> m # foldr :: (a -> b -> b) -> b -> Digit a -> b # foldr' :: (a -> b -> b) -> b -> Digit a -> b # foldl :: (b -> a -> b) -> b -> Digit a -> b # foldl' :: (b -> a -> b) -> b -> Digit a -> b # foldr1 :: (a -> a -> a) -> Digit a -> a # foldl1 :: (a -> a -> a) -> Digit a -> a # elem :: Eq a => a -> Digit a -> Bool # maximum :: Ord a => Digit a -> a # minimum :: Ord a => Digit a -> a # | |
Foldable Node | |
Defined in Data.Sequence.Internal fold :: Monoid m => Node m -> m # foldMap :: Monoid m => (a -> m) -> Node a -> m # foldr :: (a -> b -> b) -> b -> Node a -> b # foldr' :: (a -> b -> b) -> b -> Node a -> b # foldl :: (b -> a -> b) -> b -> Node a -> b # foldl' :: (b -> a -> b) -> b -> Node a -> b # foldr1 :: (a -> a -> a) -> Node a -> a # foldl1 :: (a -> a -> a) -> Node a -> a # elem :: Eq a => a -> Node a -> Bool # maximum :: Ord a => Node a -> a # | |
Foldable Elem | |
Defined in Data.Sequence.Internal fold :: Monoid m => Elem m -> m # foldMap :: Monoid m => (a -> m) -> Elem a -> m # foldr :: (a -> b -> b) -> b -> Elem a -> b # foldr' :: (a -> b -> b) -> b -> Elem a -> b # foldl :: (b -> a -> b) -> b -> Elem a -> b # foldl' :: (b -> a -> b) -> b -> Elem a -> b # foldr1 :: (a -> a -> a) -> Elem a -> a # foldl1 :: (a -> a -> a) -> Elem a -> a # elem :: Eq a => a -> Elem a -> Bool # maximum :: Ord a => Elem a -> a # | |
Foldable ViewL | |
Defined in Data.Sequence.Internal fold :: Monoid m => ViewL m -> m # foldMap :: Monoid m => (a -> m) -> ViewL a -> m # foldr :: (a -> b -> b) -> b -> ViewL a -> b # foldr' :: (a -> b -> b) -> b -> ViewL a -> b # foldl :: (b -> a -> b) -> b -> ViewL a -> b # foldl' :: (b -> a -> b) -> b -> ViewL a -> b # foldr1 :: (a -> a -> a) -> ViewL a -> a # foldl1 :: (a -> a -> a) -> ViewL a -> a # elem :: Eq a => a -> ViewL a -> Bool # maximum :: Ord a => ViewL a -> a # minimum :: Ord a => ViewL a -> a # | |
Foldable ViewR | |
Defined in Data.Sequence.Internal fold :: Monoid m => ViewR m -> m # foldMap :: Monoid m => (a -> m) -> ViewR a -> m # foldr :: (a -> b -> b) -> b -> ViewR a -> b # foldr' :: (a -> b -> b) -> b -> ViewR a -> b # foldl :: (b -> a -> b) -> b -> ViewR a -> b # foldl' :: (b -> a -> b) -> b -> ViewR a -> b # foldr1 :: (a -> a -> a) -> ViewR a -> a # foldl1 :: (a -> a -> a) -> ViewR a -> a # elem :: Eq a => a -> ViewR a -> Bool # maximum :: Ord a => ViewR a -> a # minimum :: Ord a => ViewR a -> a # | |
Foldable Set | |
Defined in Data.Set.Internal fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Foldable Hashed | |
Defined in Data.Hashable.Class fold :: Monoid m => Hashed m -> m # foldMap :: Monoid m => (a -> m) -> Hashed a -> m # foldr :: (a -> b -> b) -> b -> Hashed a -> b # foldr' :: (a -> b -> b) -> b -> Hashed a -> b # foldl :: (b -> a -> b) -> b -> Hashed a -> b # foldl' :: (b -> a -> b) -> b -> Hashed a -> b # foldr1 :: (a -> a -> a) -> Hashed a -> a # foldl1 :: (a -> a -> a) -> Hashed a -> a # elem :: Eq a => a -> Hashed a -> Bool # maximum :: Ord a => Hashed a -> a # minimum :: Ord a => Hashed a -> a # | |
Foldable HashSet | |
Defined in Data.HashSet fold :: Monoid m => HashSet m -> m # foldMap :: Monoid m => (a -> m) -> HashSet a -> m # foldr :: (a -> b -> b) -> b -> HashSet a -> b # foldr' :: (a -> b -> b) -> b -> HashSet a -> b # foldl :: (b -> a -> b) -> b -> HashSet a -> b # foldl' :: (b -> a -> b) -> b -> HashSet a -> b # foldr1 :: (a -> a -> a) -> HashSet a -> a # foldl1 :: (a -> a -> a) -> HashSet a -> a # elem :: Eq a => a -> HashSet a -> Bool # maximum :: Ord a => HashSet a -> a # minimum :: Ord a => HashSet a -> a # | |
Foldable Vector | |
Defined in Data.Vector fold :: Monoid m => Vector m -> m # foldMap :: Monoid m => (a -> m) -> Vector a -> m # foldr :: (a -> b -> b) -> b -> Vector a -> b # foldr' :: (a -> b -> b) -> b -> Vector a -> b # foldl :: (b -> a -> b) -> b -> Vector a -> b # foldl' :: (b -> a -> b) -> b -> Vector a -> b # foldr1 :: (a -> a -> a) -> Vector a -> a # foldl1 :: (a -> a -> a) -> Vector a -> a # elem :: Eq a => a -> Vector a -> Bool # maximum :: Ord a => Vector a -> a # minimum :: Ord a => Vector a -> a # | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Either a m -> m # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # toList :: Either a a0 -> [a0] # length :: Either a a0 -> Int # elem :: Eq a0 => a0 -> Either a a0 -> Bool # maximum :: Ord a0 => Either a a0 -> a0 # minimum :: Ord a0 => Either a a0 -> a0 # | |
Foldable (V1 :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => V1 m -> m # foldMap :: Monoid m => (a -> m) -> V1 a -> m # foldr :: (a -> b -> b) -> b -> V1 a -> b # foldr' :: (a -> b -> b) -> b -> V1 a -> b # foldl :: (b -> a -> b) -> b -> V1 a -> b # foldl' :: (b -> a -> b) -> b -> V1 a -> b # foldr1 :: (a -> a -> a) -> V1 a -> a # foldl1 :: (a -> a -> a) -> V1 a -> a # elem :: Eq a => a -> V1 a -> Bool # maximum :: Ord a => V1 a -> a # | |
Foldable (U1 :: * -> *) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # | |
Foldable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => (a, m) -> m # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # elem :: Eq a0 => a0 -> (a, a0) -> Bool # maximum :: Ord a0 => (a, a0) -> a0 # minimum :: Ord a0 => (a, a0) -> a0 # | |
Foldable (Array i) | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Array i m -> m # foldMap :: Monoid m => (a -> m) -> Array i a -> m # foldr :: (a -> b -> b) -> b -> Array i a -> b # foldr' :: (a -> b -> b) -> b -> Array i a -> b # foldl :: (b -> a -> b) -> b -> Array i a -> b # foldl' :: (b -> a -> b) -> b -> Array i a -> b # foldr1 :: (a -> a -> a) -> Array i a -> a # foldl1 :: (a -> a -> a) -> Array i a -> a # elem :: Eq a => a -> Array i a -> Bool # maximum :: Ord a => Array i a -> a # minimum :: Ord a => Array i a -> a # | |
Foldable (Arg a) | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Arg a m -> m # foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # elem :: Eq a0 => a0 -> Arg a a0 -> Bool # maximum :: Ord a0 => Arg a a0 -> a0 # minimum :: Ord a0 => Arg a a0 -> a0 # | |
Foldable (Proxy :: * -> *) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Foldable (Map k) | |
Defined in Data.Map.Internal fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # | |
Foldable (HashMap k) | |
Defined in Data.HashMap.Base fold :: Monoid m => HashMap k m -> m # foldMap :: Monoid m => (a -> m) -> HashMap k a -> m # foldr :: (a -> b -> b) -> b -> HashMap k a -> b # foldr' :: (a -> b -> b) -> b -> HashMap k a -> b # foldl :: (b -> a -> b) -> b -> HashMap k a -> b # foldl' :: (b -> a -> b) -> b -> HashMap k a -> b # foldr1 :: (a -> a -> a) -> HashMap k a -> a # foldl1 :: (a -> a -> a) -> HashMap k a -> a # toList :: HashMap k a -> [a] # length :: HashMap k a -> Int # elem :: Eq a => a -> HashMap k a -> Bool # maximum :: Ord a => HashMap k a -> a # minimum :: Ord a => HashMap k a -> a # | |
Foldable f => Foldable (Rec1 f) | |
Defined in Data.Foldable fold :: Monoid m => Rec1 f m -> m # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b # foldr1 :: (a -> a -> a) -> Rec1 f a -> a # foldl1 :: (a -> a -> a) -> Rec1 f a -> a # elem :: Eq a => a -> Rec1 f a -> Bool # maximum :: Ord a => Rec1 f a -> a # minimum :: Ord a => Rec1 f a -> a # | |
Foldable (URec Char :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec Char m -> m # foldMap :: Monoid m => (a -> m) -> URec Char a -> m # foldr :: (a -> b -> b) -> b -> URec Char a -> b # foldr' :: (a -> b -> b) -> b -> URec Char a -> b # foldl :: (b -> a -> b) -> b -> URec Char a -> b # foldl' :: (b -> a -> b) -> b -> URec Char a -> b # foldr1 :: (a -> a -> a) -> URec Char a -> a # foldl1 :: (a -> a -> a) -> URec Char a -> a # toList :: URec Char a -> [a] # length :: URec Char a -> Int # elem :: Eq a => a -> URec Char a -> Bool # maximum :: Ord a => URec Char a -> a # minimum :: Ord a => URec Char a -> a # | |
Foldable (URec Double :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec Double m -> m # foldMap :: Monoid m => (a -> m) -> URec Double a -> m # foldr :: (a -> b -> b) -> b -> URec Double a -> b # foldr' :: (a -> b -> b) -> b -> URec Double a -> b # foldl :: (b -> a -> b) -> b -> URec Double a -> b # foldl' :: (b -> a -> b) -> b -> URec Double a -> b # foldr1 :: (a -> a -> a) -> URec Double a -> a # foldl1 :: (a -> a -> a) -> URec Double a -> a # toList :: URec Double a -> [a] # null :: URec Double a -> Bool # length :: URec Double a -> Int # elem :: Eq a => a -> URec Double a -> Bool # maximum :: Ord a => URec Double a -> a # minimum :: Ord a => URec Double a -> a # | |
Foldable (URec Float :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec Float m -> m # foldMap :: Monoid m => (a -> m) -> URec Float a -> m # foldr :: (a -> b -> b) -> b -> URec Float a -> b # foldr' :: (a -> b -> b) -> b -> URec Float a -> b # foldl :: (b -> a -> b) -> b -> URec Float a -> b # foldl' :: (b -> a -> b) -> b -> URec Float a -> b # foldr1 :: (a -> a -> a) -> URec Float a -> a # foldl1 :: (a -> a -> a) -> URec Float a -> a # toList :: URec Float a -> [a] # null :: URec Float a -> Bool # length :: URec Float a -> Int # elem :: Eq a => a -> URec Float a -> Bool # maximum :: Ord a => URec Float a -> a # minimum :: Ord a => URec Float a -> a # | |
Foldable (URec Int :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec Int m -> m # foldMap :: Monoid m => (a -> m) -> URec Int a -> m # foldr :: (a -> b -> b) -> b -> URec Int a -> b # foldr' :: (a -> b -> b) -> b -> URec Int a -> b # foldl :: (b -> a -> b) -> b -> URec Int a -> b # foldl' :: (b -> a -> b) -> b -> URec Int a -> b # foldr1 :: (a -> a -> a) -> URec Int a -> a # foldl1 :: (a -> a -> a) -> URec Int a -> a # elem :: Eq a => a -> URec Int a -> Bool # maximum :: Ord a => URec Int a -> a # minimum :: Ord a => URec Int a -> a # | |
Foldable (URec Word :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec Word m -> m # foldMap :: Monoid m => (a -> m) -> URec Word a -> m # foldr :: (a -> b -> b) -> b -> URec Word a -> b # foldr' :: (a -> b -> b) -> b -> URec Word a -> b # foldl :: (b -> a -> b) -> b -> URec Word a -> b # foldl' :: (b -> a -> b) -> b -> URec Word a -> b # foldr1 :: (a -> a -> a) -> URec Word a -> a # foldl1 :: (a -> a -> a) -> URec Word a -> a # toList :: URec Word a -> [a] # length :: URec Word a -> Int # elem :: Eq a => a -> URec Word a -> Bool # maximum :: Ord a => URec Word a -> a # minimum :: Ord a => URec Word a -> a # | |
Foldable (URec (Ptr ()) :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => URec (Ptr ()) m -> m # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # toList :: URec (Ptr ()) a -> [a] # null :: URec (Ptr ()) a -> Bool # length :: URec (Ptr ()) a -> Int # elem :: Eq a => a -> URec (Ptr ()) a -> Bool # maximum :: Ord a => URec (Ptr ()) a -> a # minimum :: Ord a => URec (Ptr ()) a -> a # | |
Foldable (Const m :: * -> *) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
Bifoldable p => Foldable (Join p) | |
Defined in Data.Bifunctor.Join fold :: Monoid m => Join p m -> m # foldMap :: Monoid m => (a -> m) -> Join p a -> m # foldr :: (a -> b -> b) -> b -> Join p a -> b # foldr' :: (a -> b -> b) -> b -> Join p a -> b # foldl :: (b -> a -> b) -> b -> Join p a -> b # foldl' :: (b -> a -> b) -> b -> Join p a -> b # foldr1 :: (a -> a -> a) -> Join p a -> a # foldl1 :: (a -> a -> a) -> Join p a -> a # elem :: Eq a => a -> Join p a -> Bool # maximum :: Ord a => Join p a -> a # minimum :: Ord a => Join p a -> a # | |
Foldable (Forget r a) | |
Defined in Data.Profunctor.Types fold :: Monoid m => Forget r a m -> m # foldMap :: Monoid m => (a0 -> m) -> Forget r a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Forget r a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Forget r a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Forget r a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Forget r a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Forget r a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Forget r a a0 -> a0 # toList :: Forget r a a0 -> [a0] # null :: Forget r a a0 -> Bool # length :: Forget r a a0 -> Int # elem :: Eq a0 => a0 -> Forget r a a0 -> Bool # maximum :: Ord a0 => Forget r a a0 -> a0 # minimum :: Ord a0 => Forget r a a0 -> a0 # | |
Foldable f => Foldable (ErrorT e f) | |
Defined in Control.Monad.Trans.Error fold :: Monoid m => ErrorT e f m -> m # foldMap :: Monoid m => (a -> m) -> ErrorT e f a -> m # foldr :: (a -> b -> b) -> b -> ErrorT e f a -> b # foldr' :: (a -> b -> b) -> b -> ErrorT e f a -> b # foldl :: (b -> a -> b) -> b -> ErrorT e f a -> b # foldl' :: (b -> a -> b) -> b -> ErrorT e f a -> b # foldr1 :: (a -> a -> a) -> ErrorT e f a -> a # foldl1 :: (a -> a -> a) -> ErrorT e f a -> a # toList :: ErrorT e f a -> [a] # null :: ErrorT e f a -> Bool # length :: ErrorT e f a -> Int # elem :: Eq a => a -> ErrorT e f a -> Bool # maximum :: Ord a => ErrorT e f a -> a # minimum :: Ord a => ErrorT e f a -> a # | |
Foldable (Tagged s) | |
Defined in Data.Tagged fold :: Monoid m => Tagged s m -> m # foldMap :: Monoid m => (a -> m) -> Tagged s a -> m # foldr :: (a -> b -> b) -> b -> Tagged s a -> b # foldr' :: (a -> b -> b) -> b -> Tagged s a -> b # foldl :: (b -> a -> b) -> b -> Tagged s a -> b # foldl' :: (b -> a -> b) -> b -> Tagged s a -> b # foldr1 :: (a -> a -> a) -> Tagged s a -> a # foldl1 :: (a -> a -> a) -> Tagged s a -> a # elem :: Eq a => a -> Tagged s a -> Bool # maximum :: Ord a => Tagged s a -> a # minimum :: Ord a => Tagged s a -> a # | |
Foldable (K1 i c :: * -> *) | |
Defined in Data.Foldable fold :: Monoid m => K1 i c m -> m # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m # foldr :: (a -> b -> b) -> b -> K1 i c a -> b # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b # foldl :: (b -> a -> b) -> b -> K1 i c a -> b # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b # foldr1 :: (a -> a -> a) -> K1 i c a -> a # foldl1 :: (a -> a -> a) -> K1 i c a -> a # elem :: Eq a => a -> K1 i c a -> Bool # maximum :: Ord a => K1 i c a -> a # minimum :: Ord a => K1 i c a -> a # | |
(Foldable f, Foldable g) => Foldable (f :+: g) | |
Defined in Data.Foldable fold :: Monoid m => (f :+: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a # toList :: (f :+: g) a -> [a] # length :: (f :+: g) a -> Int # elem :: Eq a => a -> (f :+: g) a -> Bool # maximum :: Ord a => (f :+: g) a -> a # minimum :: Ord a => (f :+: g) a -> a # | |
(Foldable f, Foldable g) => Foldable (f :*: g) | |
Defined in Data.Foldable fold :: Monoid m => (f :*: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a # toList :: (f :*: g) a -> [a] # length :: (f :*: g) a -> Int # elem :: Eq a => a -> (f :*: g) a -> Bool # maximum :: Ord a => (f :*: g) a -> a # minimum :: Ord a => (f :*: g) a -> a # | |
(Foldable f, Foldable g) => Foldable (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product fold :: Monoid m => Product f g m -> m # foldMap :: Monoid m => (a -> m) -> Product f g a -> m # foldr :: (a -> b -> b) -> b -> Product f g a -> b # foldr' :: (a -> b -> b) -> b -> Product f g a -> b # foldl :: (b -> a -> b) -> b -> Product f g a -> b # foldl' :: (b -> a -> b) -> b -> Product f g a -> b # foldr1 :: (a -> a -> a) -> Product f g a -> a # foldl1 :: (a -> a -> a) -> Product f g a -> a # toList :: Product f g a -> [a] # null :: Product f g a -> Bool # length :: Product f g a -> Int # elem :: Eq a => a -> Product f g a -> Bool # maximum :: Ord a => Product f g a -> a # minimum :: Ord a => Product f g a -> a # | |
(Foldable f, Foldable g) => Foldable (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum fold :: Monoid m => Sum f g m -> m # foldMap :: Monoid m => (a -> m) -> Sum f g a -> m # foldr :: (a -> b -> b) -> b -> Sum f g a -> b # foldr' :: (a -> b -> b) -> b -> Sum f g a -> b # foldl :: (b -> a -> b) -> b -> Sum f g a -> b # foldl' :: (b -> a -> b) -> b -> Sum f g a -> b # foldr1 :: (a -> a -> a) -> Sum f g a -> a # foldl1 :: (a -> a -> a) -> Sum f g a -> a # elem :: Eq a => a -> Sum f g a -> Bool # maximum :: Ord a => Sum f g a -> a # minimum :: Ord a => Sum f g a -> a # | |
Foldable f => Foldable (M1 i c f) | |
Defined in Data.Foldable fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # | |
(Foldable f, Foldable g) => Foldable (f :.: g) | |
Defined in Data.Foldable fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # | |
(Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose fold :: Monoid m => Compose f g m -> m # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m # foldr :: (a -> b -> b) -> b -> Compose f g a -> b # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b # foldl :: (b -> a -> b) -> b -> Compose f g a -> b # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b # foldr1 :: (a -> a -> a) -> Compose f g a -> a # foldl1 :: (a -> a -> a) -> Compose f g a -> a # toList :: Compose f g a -> [a] # null :: Compose f g a -> Bool # length :: Compose f g a -> Int # elem :: Eq a => a -> Compose f g a -> Bool # maximum :: Ord a => Compose f g a -> a # minimum :: Ord a => Compose f g a -> a # | |
Bifoldable p => Foldable (WrappedBifunctor p a) | |
Defined in Data.Bifunctor.Wrapped fold :: Monoid m => WrappedBifunctor p a m -> m # foldMap :: Monoid m => (a0 -> m) -> WrappedBifunctor p a a0 -> m # foldr :: (a0 -> b -> b) -> b -> WrappedBifunctor p a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> WrappedBifunctor p a a0 -> b # foldl :: (b -> a0 -> b) -> b -> WrappedBifunctor p a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> WrappedBifunctor p a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> WrappedBifunctor p a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> WrappedBifunctor p a a0 -> a0 # toList :: WrappedBifunctor p a a0 -> [a0] # null :: WrappedBifunctor p a a0 -> Bool # length :: WrappedBifunctor p a a0 -> Int # elem :: Eq a0 => a0 -> WrappedBifunctor p a a0 -> Bool # maximum :: Ord a0 => WrappedBifunctor p a a0 -> a0 # minimum :: Ord a0 => WrappedBifunctor p a a0 -> a0 # sum :: Num a0 => WrappedBifunctor p a a0 -> a0 # product :: Num a0 => WrappedBifunctor p a a0 -> a0 # | |
Foldable g => Foldable (Joker g a) | |
Defined in Data.Bifunctor.Joker fold :: Monoid m => Joker g a m -> m # foldMap :: Monoid m => (a0 -> m) -> Joker g a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Joker g a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Joker g a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Joker g a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Joker g a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Joker g a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Joker g a a0 -> a0 # toList :: Joker g a a0 -> [a0] # null :: Joker g a a0 -> Bool # length :: Joker g a a0 -> Int # elem :: Eq a0 => a0 -> Joker g a a0 -> Bool # maximum :: Ord a0 => Joker g a a0 -> a0 # minimum :: Ord a0 => Joker g a a0 -> a0 # | |
Bifoldable p => Foldable (Flip p a) | |
Defined in Data.Bifunctor.Flip fold :: Monoid m => Flip p a m -> m # foldMap :: Monoid m => (a0 -> m) -> Flip p a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Flip p a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Flip p a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Flip p a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Flip p a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Flip p a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Flip p a a0 -> a0 # toList :: Flip p a a0 -> [a0] # length :: Flip p a a0 -> Int # elem :: Eq a0 => a0 -> Flip p a a0 -> Bool # maximum :: Ord a0 => Flip p a a0 -> a0 # minimum :: Ord a0 => Flip p a a0 -> a0 # | |
Foldable (Clown f a :: * -> *) | |
Defined in Data.Bifunctor.Clown fold :: Monoid m => Clown f a m -> m # foldMap :: Monoid m => (a0 -> m) -> Clown f a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Clown f a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Clown f a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Clown f a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Clown f a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Clown f a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Clown f a a0 -> a0 # toList :: Clown f a a0 -> [a0] # null :: Clown f a a0 -> Bool # length :: Clown f a a0 -> Int # elem :: Eq a0 => a0 -> Clown f a a0 -> Bool # maximum :: Ord a0 => Clown f a a0 -> a0 # minimum :: Ord a0 => Clown f a a0 -> a0 # | |
(Foldable f, Bifoldable p) => Foldable (Tannen f p a) | |
Defined in Data.Bifunctor.Tannen fold :: Monoid m => Tannen f p a m -> m # foldMap :: Monoid m => (a0 -> m) -> Tannen f p a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Tannen f p a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Tannen f p a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Tannen f p a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Tannen f p a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Tannen f p a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Tannen f p a a0 -> a0 # toList :: Tannen f p a a0 -> [a0] # null :: Tannen f p a a0 -> Bool # length :: Tannen f p a a0 -> Int # elem :: Eq a0 => a0 -> Tannen f p a a0 -> Bool # maximum :: Ord a0 => Tannen f p a a0 -> a0 # minimum :: Ord a0 => Tannen f p a a0 -> a0 # | |
(Bifoldable p, Foldable g) => Foldable (Biff p f g a) | |
Defined in Data.Bifunctor.Biff fold :: Monoid m => Biff p f g a m -> m # foldMap :: Monoid m => (a0 -> m) -> Biff p f g a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Biff p f g a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Biff p f g a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Biff p f g a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Biff p f g a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Biff p f g a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Biff p f g a a0 -> a0 # toList :: Biff p f g a a0 -> [a0] # null :: Biff p f g a a0 -> Bool # length :: Biff p f g a a0 -> Int # elem :: Eq a0 => a0 -> Biff p f g a a0 -> Bool # maximum :: Ord a0 => Biff p f g a a0 -> a0 # minimum :: Ord a0 => Biff p f g a a0 -> a0 # |
RealWorld
is deeply magical. It is primitive, but it is not
unlifted (hence ptrArg
). We never manipulate values of type
RealWorld
; it's only used in the type system, to parameterise State#
.
groupBy :: Ord g => (a -> g) -> Fold a r -> Fold a (Map g r) #
Perform a Fold
while grouping the data according to a specified group
projection function. Returns the folded result grouped as a map keyed by the
group.
filtered :: Monoid m => (a -> Bool) -> (a -> m) -> a -> m #
>>>
fold (handles (filtered even) sum) [1..10]
30
>>>
foldM (handlesM (filtered even) (mapM_ print)) [1..10]
2 4 6 8 10
folded :: (Contravariant f, Applicative f, Foldable t) => (a -> f a) -> t a -> f (t a) #
folded :: Foldable t => Fold (t a) a handles folded :: Foldable t => Fold a r -> Fold (t a) r
foldOverM :: Monad m => HandlerM m s a -> FoldM m a b -> s -> m b #
(foldOverM f folder xs)
folds all values from a Lens, Traversal, Prism or Fold monadically with the given folder
L.foldOverM (folded.f) folder == L.foldM (handlesM f folder)
L.foldOverM folded == L.foldM
handlesM :: HandlerM m a b -> FoldM m b r -> FoldM m a r #
(handlesM t folder)
transforms the input of a FoldM
using a lens,
traversal, or prism:
handlesM _1 :: FoldM m a r -> FoldM (a, b) r handlesM _Left :: FoldM m a r -> FoldM (Either a b) r handlesM traverse :: Traversable t => FoldM m a r -> FoldM m (t a) r handlesM folded :: Foldable t => FoldM m a r -> FoldM m (t a) r
handlesM
obeys these laws:
handlesM id = id handlesM (f . g) = handlesM f . handlesM g
handlesM t (pure r) = pure r handlesM t (f <*> x) = handlesM t f <*> handlesM t x
foldOver :: Handler s a -> Fold a b -> s -> b #
(foldOver f folder xs)
folds all values from a Lens, Traversal, Prism or Fold with the given folder
>>>
foldOver (_Just . both) L.sum (Just (2, 3))
5
>>>
foldOver (_Just . both) L.sum Nothing
0
L.foldOver f folder xs == L.fold folder (xs^..f)
L.foldOver (folded.f) folder == L.fold (handles f folder)
L.foldOver folded == L.fold
handles :: Handler a b -> Fold b r -> Fold a r #
(handles t folder)
transforms the input of a Fold
using a lens,
traversal, or prism:
handles _1 :: Fold a r -> Fold (a, b) r handles _Left :: Fold a r -> Fold (Either a b) r handles traverse :: Traversable t => Fold a r -> Fold (t a) r handles folded :: Foldable t => Fold a r -> Fold (t a) r
>>>
fold (handles traverse sum) [[1..5],[6..10]]
55
>>>
fold (handles (traverse.traverse) sum) [[Nothing, Just 2, Just 7],[Just 13, Nothing, Just 20]]
42
>>>
fold (handles (filtered even) sum) [1..10]
30
>>>
fold (handles _2 mconcat) [(1,"Hello "),(2,"World"),(3,"!")]
"Hello World!"
handles id = id handles (f . g) = handles f . handles g
handles t (pure r) = pure r handles t (f <*> x) = handles t f <*> handles t x
prefilterM :: Monad m => (a -> m Bool) -> FoldM m a r -> FoldM m a r #
(prefilterM f folder)
returns a new Fold
where the folder's input is used
only when the input satisfies a monadic predicate f.
foldM (prefilterM p folder) list = foldM folder (filter p list)
prefilter :: (a -> Bool) -> Fold a r -> Fold a r #
(prefilter f folder)
returns a new Fold
where the folder's input is used
only when the input satisfies a predicate f
This can also be done with handles
(handles (filtered f)
) but prefilter
does not need you to depend on a lens library.
fold (prefilter p folder) list = fold folder (filter p list)
>>>
fold (prefilter (>5) Control.Foldl.sum) [1..10]
40
>>>
fold Control.Foldl.sum (filter (>5) [1..10])
40
premapM :: Monad m => (a -> m b) -> FoldM m b r -> FoldM m a r #
(premapM f folder)
returns a new FoldM
where f is applied to each input
element
premapM return = id premapM (f <=< g) = premap g . premap f
premapM k (pure r) = pure r premapM k (f <*> x) = premapM k f <*> premapM k x
premap :: (a -> b) -> Fold b r -> Fold a r #
(premap f folder)
returns a new Fold
where f is applied at each step
fold (premap f folder) list = fold folder (map f list)
>>>
fold (premap Sum mconcat) [1..10]
Sum {getSum = 55}
>>>
fold mconcat (map Sum [1..10])
Sum {getSum = 55}
premap id = id premap (f . g) = premap g . premap f
premap k (pure r) = pure r premap k (f <*> x) = premap k f <*> premap k x
duplicateM :: Applicative m => FoldM m a b -> FoldM m a (FoldM m a b) #
generalize :: Monad m => Fold a b -> FoldM m a b #
impurely_ :: Monad m => (forall x. (x -> a -> m x) -> m x -> m x) -> FoldM m a b -> m b #
Upgrade a more traditional monadic fold to accept the FoldM
type
impurely :: (forall x. (x -> a -> m x) -> m x -> (x -> m b) -> r) -> FoldM m a b -> r #
Upgrade a monadic fold to accept the FoldM
type
purely_ :: (forall x. (x -> a -> x) -> x -> x) -> Fold a b -> b #
Upgrade a more traditional fold to accept the Fold
type
purely :: (forall x. (x -> a -> x) -> x -> (x -> b) -> r) -> Fold a b -> r #
Upgrade a fold to accept the Fold
type
vectorM :: (PrimMonad m, Vector v a) => FoldM m a (v a) #
Fold all values into a vector
This is more efficient than vector
but is impure
O(n^2). Fold values into a list with duplicates removed, while preserving their first occurrences
O(n log n). Fold values into a list with duplicates removed, while preserving their first occurrences
genericIndex :: Integral i => i -> Fold a (Maybe a) #
sink :: (Monoid w, Monad m) => (a -> m w) -> FoldM m a w #
Converts an effectful function to a fold
sink (f <> g) = sink f <> sink g -- if `(<>)` is commutative sink mempty = mempty
mapM_ :: Monad m => (a -> m ()) -> FoldM m a () #
Converts an effectful function to a fold. Specialized version of sink
.
randomN :: Vector v a => Int -> FoldM IO a (Maybe (v a)) #
Pick several random elements, using reservoir sampling
lookup :: Eq a => a -> Fold (a, b) (Maybe b) #
(lookup a)
returns the element paired with the first matching item, or
Nothing
if none matches
findIndex :: (a -> Bool) -> Fold a (Maybe Int) #
(findIndex predicate)
returns the index of the first element that
satisfies the predicate, or Nothing
if no element satisfies the predicate
elemIndex :: Eq a => a -> Fold a (Maybe Int) #
(elemIndex a)
returns the index of the first element that equals a
, or
Nothing
if no element matches
index :: Int -> Fold a (Maybe a) #
(index n)
returns the n
th element of the container, or Nothing
if the
container has an insufficient number of elements
find :: (a -> Bool) -> Fold a (Maybe a) #
(find predicate)
returns the first element that satisfies the predicate or
Nothing
if no element satisfies the predicate
minimumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) #
Computes the minimum element with respect to the given comparison function
maximumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) #
Computes the maximum element with respect to the given comparison function
std :: Floating a => Fold a a #
Compute a numerically stable (population) standard deviation over all elements
Get the last element of a container or return a default value if the container is empty
Get the last element of a container or return Nothing
if the container is
empty
Get the first element of a container or return Nothing
if the container is
empty
postscan :: Traversable t => Fold a b -> t a -> t b #
Convert a Fold
into a postscan for any Traversable
type
"Postscan" means that the first element of the scan is not included
prescan :: Traversable t => Fold a b -> t a -> t b #
Convert a Fold
into a prescan for any Traversable
type
"Prescan" means that the last element of the scan is not included
Efficient representation of a left fold that preserves the fold's step function, initial accumulator, and extraction function
This allows the Applicative
instance to assemble derived folds that
traverse the container only once
A 'Fold
a b' processes elements of type a and results in a
value of type b.
Instances
Choice Fold | |
Profunctor Fold | |
Functor (Fold a) | |
Applicative (Fold a) | |
Comonad (Fold a) | |
Semigroupoid Fold | |
Floating b => Floating (Fold a b) | |
Defined in Control.Foldl sqrt :: Fold a b -> Fold a b # (**) :: Fold a b -> Fold a b -> Fold a b # logBase :: Fold a b -> Fold a b -> Fold a b # asin :: Fold a b -> Fold a b # acos :: Fold a b -> Fold a b # atan :: Fold a b -> Fold a b # sinh :: Fold a b -> Fold a b # cosh :: Fold a b -> Fold a b # tanh :: Fold a b -> Fold a b # asinh :: Fold a b -> Fold a b # acosh :: Fold a b -> Fold a b # atanh :: Fold a b -> Fold a b # log1p :: Fold a b -> Fold a b # expm1 :: Fold a b -> Fold a b # | |
Fractional b => Fractional (Fold a b) | |
Num b => Num (Fold a b) | |
Semigroup b => Semigroup (Fold a b) | |
Monoid b => Monoid (Fold a b) | |
data FoldM (m :: * -> *) a b where #
Like Fold
, but monadic.
A 'FoldM
m a b' processes elements of type a and
results in a monadic value of type m b.
Instances
Functor m => Profunctor (FoldM m) | |
Defined in Control.Foldl | |
Functor m => Functor (FoldM m a) | |
Applicative m => Applicative (FoldM m a) | |
(Monad m, Floating b) => Floating (FoldM m a b) | |
Defined in Control.Foldl exp :: FoldM m a b -> FoldM m a b # log :: FoldM m a b -> FoldM m a b # sqrt :: FoldM m a b -> FoldM m a b # (**) :: FoldM m a b -> FoldM m a b -> FoldM m a b # logBase :: FoldM m a b -> FoldM m a b -> FoldM m a b # sin :: FoldM m a b -> FoldM m a b # cos :: FoldM m a b -> FoldM m a b # tan :: FoldM m a b -> FoldM m a b # asin :: FoldM m a b -> FoldM m a b # acos :: FoldM m a b -> FoldM m a b # atan :: FoldM m a b -> FoldM m a b # sinh :: FoldM m a b -> FoldM m a b # cosh :: FoldM m a b -> FoldM m a b # tanh :: FoldM m a b -> FoldM m a b # asinh :: FoldM m a b -> FoldM m a b # acosh :: FoldM m a b -> FoldM m a b # atanh :: FoldM m a b -> FoldM m a b # log1p :: FoldM m a b -> FoldM m a b # expm1 :: FoldM m a b -> FoldM m a b # | |
(Monad m, Fractional b) => Fractional (FoldM m a b) | |
(Monad m, Num b) => Num (FoldM m a b) | |
Defined in Control.Foldl (+) :: FoldM m a b -> FoldM m a b -> FoldM m a b # (-) :: FoldM m a b -> FoldM m a b -> FoldM m a b # (*) :: FoldM m a b -> FoldM m a b -> FoldM m a b # negate :: FoldM m a b -> FoldM m a b # abs :: FoldM m a b -> FoldM m a b # signum :: FoldM m a b -> FoldM m a b # fromInteger :: Integer -> FoldM m a b # | |
(Semigroup b, Monad m) => Semigroup (FoldM m a b) | |
(Monoid b, Monad m) => Monoid (FoldM m a b) | |
newtype EndoM (m :: * -> *) a #
instance Monad m => Monoid (EndoM m a) where mempty = EndoM return mappend (EndoM f) (EndoM g) = EndoM (f <=< g)
type HandlerM (m :: * -> *) a b = forall x. (b -> Const (Dual (EndoM m x)) b) -> a -> Const (Dual (EndoM m x)) a #
class MVector (Mutable v) a => Vector (v :: * -> *) a #
Class of immutable vectors. Every immutable vector is associated with its
mutable version through the Mutable
type family. Methods of this class
should not be used directly. Instead, Data.Vector.Generic and other
Data.Vector modules provide safe and fusible wrappers.
Minimum complete implementation:
Instances
type family Mutable (v :: * -> *) :: * -> * -> * #
Mutable v s a
is the mutable version of the pure vector type v a
with
the state token s
class Monad m => PrimMonad (m :: * -> *) #
Class of monads which can perform primitive state-transformer actions
Instances
PrimMonad IO | |
PrimMonad (ST s) | |
PrimMonad m => PrimMonad (MaybeT m) | |
PrimMonad m => PrimMonad (ListT m) | |
PrimMonad m => PrimMonad (IdentityT m) | |
(Error e, PrimMonad m) => PrimMonad (ErrorT e m) | |
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) | |
(Monoid w, PrimMonad m) => PrimMonad (AccumT w m) | Since: primitive-0.6.3.0 |
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) | |
PrimMonad m => PrimMonad (StateT s m) | |
PrimMonad m => PrimMonad (StateT s m) | |
PrimMonad m => PrimMonad (SelectT r m) | |
PrimMonad m => PrimMonad (ExceptT e m) | |
PrimMonad m => PrimMonad (ReaderT r m) | |
PrimMonad m => PrimMonad (ContT r m) | Since: primitive-0.6.3.0 |
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) | |
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) | |