HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulereducers-3.12.5Haskell2010

Data.Semigroup.Reducer

A c-Reducer is a Semigroup with a canonical mapping from c to the Semigroup.

  • 1 type
  • 1 class
  • 6 values
  • Packagereducers-3.12.5
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceReducer.hs
classclass Semigroup m => Reducer c m where
#

This type may be best read infix. A c Reducer m is a Semigroup 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

Methods

  • unit :: c -> m

    Convert a value into a Semigroup

  • snoc :: m -> c -> m

    Append a value to a Semigroup for use in left-to-right reduction

  • cons :: c -> m -> m

    Prepend a value onto a Semigroup for use during right-to-left reduction

Instances39Reducer, …
newtypenewtype Count
#

Constructors

Instances9Eq, Data, Ord, Read, Show, Semigroup, …
  • Eq CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Data CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Ord CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Read CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Show CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Semigroup CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Monoid CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Hashable CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer
  • Reducer a CountDefined in reducers-3.12.5 · Data.Semigroup.Reducer