lens-3.8.7.3: Lenses, Folds and Traversals

Portability | non-portable
Stability | experimental
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | Trustworthy

Control.Lens.Internal.Fold

Contents

- Monoids for folding

Description

Synopsis

- newtype Folding f a = Folding {
  - getFolding :: f a
  }
- newtype Traversed a f = Traversed {
  - getTraversed :: f a
  }
- newtype Sequenced a m = Sequenced {
  - getSequenced :: m a
  }
- data Max a
  - = NoMax
  - | Max a
- getMax :: Max a -> Maybe a
- data Min a
  - = NoMin
  - | Min a
- getMin :: Min a -> Maybe a
- data Leftmost a
  - = LPure
  - | LLeaf a
  - | LStep (Leftmost a)
- getLeftmost :: Leftmost a -> Maybe a
- data Rightmost a
  - = RPure
  - | RLeaf a
  - | RStep (Rightmost a)
- getRightmost :: Rightmost a -> Maybe a

# Monoids for folding

newtype Folding f a

A `Monoid` for a `Gettable` `Applicative`.

Constructors

Folding |

Fields

getFolding :: f a

Instances

(Gettable f, Applicative f) => Monoid (Folding f a) |
(Gettable f, Apply f) => Semigroup (Folding f a) |

newtype Traversed a f

Used internally by `traverseOf_` and the like.

The argument `a` of the result should not be used!

Constructors

Traversed |

Fields

getTraversed :: f a

Instances

Applicative f => Monoid (Traversed a f) |
Apply f => Semigroup (Traversed a f) |

newtype Sequenced a m

Used internally by `mapM_` and the like.

The argument `a` of the result should not be used!

Constructors

Sequenced |

Fields

getSequenced :: m a

Instances

Monad m => Monoid (Sequenced a m) |
Apply m => Semigroup (Sequenced a m) |

data Max a

Used for `maximumOf`.

Constructors

NoMax |
Max a |

Instances

Ord a => Monoid (Max a) |
Ord a => Semigroup (Max a) |

getMax :: Max a -> Maybe a

Obtain the maximum.

data Min a

Used for `minimumOf`.

Constructors

NoMin |
Min a |

Instances

Ord a => Monoid (Min a) |
Ord a => Semigroup (Min a) |

getMin :: Min a -> Maybe a

Obtain the minimum.

data Leftmost a

Used for `preview`.

Constructors

LPure |
LLeaf a |
LStep (Leftmost a) |

Instances

Monoid (Leftmost a) |
Semigroup (Leftmost a) |

getLeftmost :: Leftmost a -> Maybe a

Extract the `Leftmost` element. This will fairly eagerly determine that it can return `Just` the moment it sees any element at all.

data Rightmost a

Used for `lastOf`.

Constructors

RPure |
RLeaf a |
RStep (Rightmost a) |

Instances

Monoid (Rightmost a) |
Semigroup (Rightmost a) |

getRightmost :: Rightmost a -> Maybe a

Extract the `Rightmost` element. This will fairly eagerly determine that it can return `Just` the moment it sees any element at all.