lens-4.13: Lenses, Folds and Traversals

Copyright | (C) 2012-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe
Language | Haskell98

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
- data ReifiedMonoid a :: * -> * = ReifiedMonoid {
  - reifiedMappend :: a -> a -> a
  - reifiedMempty :: a
  }

# Monoids for folding

newtype Folding f a Source

A `Monoid` for a `Contravariant` `Applicative`.

Constructors

Folding |

Fields

getFolding :: f a

Instances

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

newtype Traversed a f Source

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) Source |
Apply f => Semigroup (Traversed a f) Source |

newtype Sequenced a m Source

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) Source |
Apply m => Semigroup (Sequenced a m) Source |

data Max a Source

Used for `maximumOf`.

Constructors

NoMax |
Max a |

Instances

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

getMax :: Max a -> Maybe a Source

Obtain the maximum.

data Min a Source

Used for `minimumOf`.

Constructors

NoMin |
Min a |

Instances

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

getMin :: Min a -> Maybe a Source

Obtain the minimum.

data Leftmost a Source

Used for `preview`.

Constructors

LPure |
LLeaf a |
LStep (Leftmost a) |

Instances

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

getLeftmost :: Leftmost a -> Maybe a Source

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 Source

Used for `lastOf`.

Constructors

RPure |
RLeaf a |
RStep (Rightmost a) |

Instances

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

getRightmost :: Rightmost a -> Maybe a Source

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

data ReifiedMonoid a :: * -> *

Constructors

ReifiedMonoid |

Fields

reifiedMappend :: a -> a -> a
reifiedMempty :: a