foldl-1.4.15: Composable, streaming, and efficient left folds

Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Foldl.NonEmpty

Description

This module provides a `Fold1` type that is a "non-empty" analog of the `Fold` type, meaning that it requires at least one input element in order to produce a result

This module does not provide all of the same utilities as the Control.Foldl module. Instead, this module only provides the utilities which can make use of the non-empty input guarantee (e.g. `head`). For all other utilities you can convert them from the equivalent `Fold` using `fromFold`.

Synopsis

- data Fold1 a b = Fold1 (a -> Fold a b)
- fold1 :: Foldable1 f => Fold1 a b -> f a -> b
- fromFold :: Fold a b -> Fold1 a b
- toFold :: Fold1 a b -> Fold a (Maybe b)
- nonEmpty :: Fold1 a (NonEmpty a)
- sconcat :: Semigroup a => Fold1 a a
- head :: Fold1 a a
- last :: Fold1 a a
- maximum :: Ord a => Fold1 a a
- maximumBy :: (a -> a -> Ordering) -> Fold1 a a
- minimum :: Ord a => Fold1 a a
- minimumBy :: (a -> a -> Ordering) -> Fold1 a a

# Documentation

data Fold1 a b Source #

A `Fold1` is like a `Fold` except that it consumes at least one input element

Constructors

Fold1 (a -> Fold a b) |

#### Instances

Instances details

Profunctor Fold1 Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods dimap :: (a -> b) -> (c -> d) -> Fold1 b c -> Fold1 a d Source # lmap :: (a -> b) -> Fold1 b c -> Fold1 a c Source # rmap :: (b -> c) -> Fold1 a b -> Fold1 a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Fold1 a b -> Fold1 a c Source # (.#) :: forall a b c q. Coercible b a => Fold1 b c -> q a b -> Fold1 a c Source #
Applicative (Fold1 a) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods pure :: a0 -> Fold1 a a0 Source # (<*>) :: Fold1 a (a0 -> b) -> Fold1 a a0 -> Fold1 a b Source # liftA2 :: (a0 -> b -> c) -> Fold1 a a0 -> Fold1 a b -> Fold1 a c Source # (*>) :: Fold1 a a0 -> Fold1 a b -> Fold1 a b Source # (<*) :: Fold1 a a0 -> Fold1 a b -> Fold1 a a0 Source #
Functor (Fold1 a) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods fmap :: (a0 -> b) -> Fold1 a a0 -> Fold1 a b Source # (<$) :: a0 -> Fold1 a b -> Fold1 a a0 Source #
Monoid b => Monoid (Fold1 a b) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods mempty :: Fold1 a b Source # mappend :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # mconcat :: [Fold1 a b] -> Fold1 a b Source #
Semigroup b => Semigroup (Fold1 a b) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods (<>) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # sconcat :: NonEmpty (Fold1 a b) -> Fold1 a b Source # stimes :: Integral b0 => b0 -> Fold1 a b -> Fold1 a b Source #
Floating b => Floating (Fold1 a b) Source # |

Instance details

Defined in Control.Foldl.NonEmpty

Methods

pi :: Fold1 a b Source #

exp :: Fold1 a b -> Fold1 a b Source #

log :: Fold1 a b -> Fold1 a b Source #

sqrt :: Fold1 a b -> Fold1 a b Source #

(**) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source #

logBase :: Fold1 a b -> Fold1 a b -> Fold1 a b Source #

sin :: Fold1 a b -> Fold1 a b Source #

cos :: Fold1 a b -> Fold1 a b Source #

tan :: Fold1 a b -> Fold1 a b Source #

asin :: Fold1 a b -> Fold1 a b Source #

acos :: Fold1 a b -> Fold1 a b Source #

atan :: Fold1 a b -> Fold1 a b Source #

sinh :: Fold1 a b -> Fold1 a b Source #

cosh :: Fold1 a b -> Fold1 a b Source #

tanh :: Fold1 a b -> Fold1 a b Source #

asinh :: Fold1 a b -> Fold1 a b Source #

acosh :: Fold1 a b -> Fold1 a b Source #

atanh :: Fold1 a b -> Fold1 a b Source #

log1p :: Fold1 a b -> Fold1 a b Source #

expm1 :: Fold1 a b -> Fold1 a b Source #

log1pexp :: Fold1 a b -> Fold1 a b Source #

log1mexp :: Fold1 a b -> Fold1 a b Source #

Num b => Num (Fold1 a b) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods (+) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # (-) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # (*) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # negate :: Fold1 a b -> Fold1 a b Source # abs :: Fold1 a b -> Fold1 a b Source # signum :: Fold1 a b -> Fold1 a b Source # fromInteger :: Integer -> Fold1 a b Source #
Fractional b => Fractional (Fold1 a b) Source # |
Instance details Defined in Control.Foldl.NonEmpty Methods (/) :: Fold1 a b -> Fold1 a b -> Fold1 a b Source # recip :: Fold1 a b -> Fold1 a b Source # fromRational :: Rational -> Fold1 a b Source #

fold1 :: Foldable1 f => Fold1 a b -> f a -> b Source #

Apply a strict left `Fold1` to a `NonEmpty` list

fromFold :: Fold a b -> Fold1 a b Source #

Promote any `Fold` to an equivalent `Fold1`

toFold :: Fold1 a b -> Fold a (Maybe b) Source #

Promote any `Fold1` to an equivalent `Fold`

nonEmpty :: Fold1 a (NonEmpty a) Source #

Fold all values within a non-empty container into a `NonEmpty` list

sconcat :: Semigroup a => Fold1 a a Source #

Fold all values within a non-empty container using (`<>`)

head :: Fold1 a a Source #

Get the first element of a non-empty container

last :: Fold1 a a Source #

Get the last element of a non-empty container

maximum :: Ord a => Fold1 a a Source #

Computes the maximum element

maximumBy :: (a -> a -> Ordering) -> Fold1 a a Source #

Computes the maximum element with respect to the given comparison function

minimum :: Ord a => Fold1 a a Source #

Computes the minimum element

minimumBy :: (a -> a -> Ordering) -> Fold1 a a Source #

Computes the minimum element with respect to the given comparison function