|
Data.Monoid.Reducer | Portability | non-portable (MPTCs) | Stability | experimental | Maintainer | ekmett@gmail.com |
|
|
|
Description |
A c-Reducer is a Monoid with a canonical mapping from c to the Monoid.
This unit acts in many ways like return for a Monad but is limited
to a single type.
|
|
Synopsis |
|
|
|
Documentation |
|
|
This type may be best read infix. A c Reducer m is a Monoid m that maps
values of type c through unit to values of type m. A c-Reducer may also
supply operations which tack-on another c to an existing Monoid m on the left
or right. These specialized reductions may be more efficient in some scenarios
and are used when appropriate by a Generator. The names cons and snoc work
by analogy to the synonymous operations in the list monoid.
This class deliberately avoids functional-dependencies, so that () can be a c-Reducer
for all c, and so many common reducers can work over multiple types, for instance,
First and Last may reduce both a and Maybe a. Since a Generator has a fixed element
type, the input to the reducer is generally known and extracting from the monoid usually
is sufficient to fix the result type. Combinators are available for most scenarios where
this is not the case, and the few remaining cases can be handled by using an explicit
type annotation.
Minimal definition: unit or snoc
| | Methods | | Convert a value into a Monoid
| | | Append a value to a Monoid for use in left-to-right reduction
| | | Prepend a value onto a Monoid for use during right-to-left reduction
|
| | Instances | Reducer Bool All | Reducer Bool All | Reducer Bool Any | Reducer Bool Any | Reducer c () | Reducer a (Last a) | Reducer a (First a) | Num a => Reducer a (Product a) | Num a => Reducer a (Sum a) | Monoid a => Reducer a (Dual a) | Reducer c ([] c) | Monoid m => Reducer m (Self m) | HasUnion f => Reducer f (Union f) | (Ord a, Bounded a) => Reducer a (Min a) | (Ord a, Bounded a) => Reducer a (Max a) | (Reducer c m, Reducer c n) => Reducer c ((,) m n) | (Reducer c m, Applicative f) => Reducer c (App f m) | (Reducer c m, Monad f) => Reducer c (Mon f m) | (Reducer c m, Reducer c n, Reducer c o) => Reducer c ((,,) m n o) | (Reducer c m, Reducer c n, Reducer c o, Reducer c p) => Reducer c ((,,,) m n o p) | Applicative f => Reducer (f a) (Traversal f) | Monad m => Reducer (m a) (Action m) | Reducer (Maybe a) (Last a) | Reducer (Maybe a) (Last a) | Reducer (Maybe a) (First a) | Reducer (Maybe a) (First a) | Ord a => Reducer (Maybe a) (MinPriority a) | Ord a => Reducer (Maybe a) (MinPriority a) | Ord a => Reducer (Maybe a) (MaxPriority a) | Ord a => Reducer (Maybe a) (MaxPriority a) | (HasUnionWith f, Monoid m) => Reducer (f m) (UnionWith f m) | Alternative f => Reducer (f a) (Alt f a) | MonadPlus m => Reducer (m a) (MonadSum m a) | Reducer (a -> a) (Endo a) | Reducer (a -> a) (Endo a) |
|
|
|
|
Apply a Reducer to a Foldable container, after mapping the contents into a suitable form for reduction.
|
|
|
Apply a Reducer to a Foldable mapping each element through unit
|
|
|
|
|
|
Produced by Haddock version 2.4.2 |