lens-5.3.3: Lenses, Folds and Traversals

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

Control.Lens.Internal.Fold

Contents

- Monoids for folding
- Semigroups for folding

Description

Synopsis

- newtype Folding (f :: Type -> Type) a = Folding {
  - getFolding :: f a
  }
- newtype Traversed a (f :: Type -> Type) = Traversed {
  - getTraversed :: f a
  }
- newtype TraversedF a (f :: Type -> Type) = TraversedF {
  - getTraversedF :: f a
  }
- newtype Sequenced a (m :: Type -> Type) = Sequenced {
  - getSequenced :: m 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
  }
- newtype NonEmptyDList a = NonEmptyDList {
  - getNonEmptyDList :: [a] -> NonEmpty a
  }

# Monoids for folding

newtype Folding (f :: Type -> Type) a #

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

Constructors

Folding |
Fields getFolding :: f a

#### Instances

Instances details

(Contravariant f, Applicative f) => Monoid (Folding f a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: Folding f a # mappend :: Folding f a -> Folding f a -> Folding f a # mconcat :: [Folding f a] -> Folding f a #
(Contravariant f, Applicative f) => Semigroup (Folding f a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: Folding f a -> Folding f a -> Folding f a # sconcat :: NonEmpty (Folding f a) -> Folding f a # stimes :: Integral b => b -> Folding f a -> Folding f a #

newtype Traversed a (f :: Type -> Type) #

Used internally by `traverseOf_` and the like.

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

Constructors

Traversed |
Fields getTraversed :: f a

#### Instances

Instances details

Applicative f => Monoid (Traversed a f) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: Traversed a f # mappend :: Traversed a f -> Traversed a f -> Traversed a f # mconcat :: [Traversed a f] -> Traversed a f #
Applicative f => Semigroup (Traversed a f) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: Traversed a f -> Traversed a f -> Traversed a f # sconcat :: NonEmpty (Traversed a f) -> Traversed a f # stimes :: Integral b => b -> Traversed a f -> Traversed a f #

newtype TraversedF a (f :: Type -> Type) #

Used internally by `traverse1Of_` and the like.

Since: 4.16

Constructors

TraversedF |
Fields getTraversedF :: f a

#### Instances

Instances details

(Apply f, Applicative f) => Monoid (TraversedF a f) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: TraversedF a f # mappend :: TraversedF a f -> TraversedF a f -> TraversedF a f # mconcat :: [TraversedF a f] -> TraversedF a f #
Apply f => Semigroup (TraversedF a f) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: TraversedF a f -> TraversedF a f -> TraversedF a f # sconcat :: NonEmpty (TraversedF a f) -> TraversedF a f # stimes :: Integral b => b -> TraversedF a f -> TraversedF a f #

newtype Sequenced a (m :: Type -> Type) #

Used internally by `mapM_` and the like.

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

See 4.16 Changelog entry for the explanation of "why not Apply f =>"?

Constructors

Sequenced |
Fields getSequenced :: m a

#### Instances

Instances details

Monad m => Monoid (Sequenced a m) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: Sequenced a m # mappend :: Sequenced a m -> Sequenced a m -> Sequenced a m # mconcat :: [Sequenced a m] -> Sequenced a m #
Monad m => Semigroup (Sequenced a m) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: Sequenced a m -> Sequenced a m -> Sequenced a m # sconcat :: NonEmpty (Sequenced a m) -> Sequenced a m # stimes :: Integral b => b -> Sequenced a m -> Sequenced a m #

data Leftmost a #

Used for `firstOf`.

Constructors

LPure |
LLeaf a |
LStep (Leftmost a) |

#### Instances

Instances details

Monoid (Leftmost a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: Leftmost a # mappend :: Leftmost a -> Leftmost a -> Leftmost a # mconcat :: [Leftmost a] -> Leftmost a #
Semigroup (Leftmost a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: Leftmost a -> Leftmost a -> Leftmost a # sconcat :: NonEmpty (Leftmost a) -> Leftmost a # stimes :: Integral b => b -> Leftmost a -> 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

Instances details

Monoid (Rightmost a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods mempty :: Rightmost a # mappend :: Rightmost a -> Rightmost a -> Rightmost a # mconcat :: [Rightmost a] -> Rightmost a #
Semigroup (Rightmost a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: Rightmost a -> Rightmost a -> Rightmost a # sconcat :: NonEmpty (Rightmost a) -> Rightmost a # stimes :: Integral b => b -> Rightmost a -> 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.

data ReifiedMonoid a #

Constructors

ReifiedMonoid |
Fields reifiedMappend :: a -> a -> a reifiedMempty :: a

# Semigroups for folding

newtype NonEmptyDList a #

Constructors

NonEmptyDList |
Fields getNonEmptyDList :: [a] -> NonEmpty a

#### Instances

Instances details

Semigroup (NonEmptyDList a) # |
Instance details Defined in Control.Lens.Internal.Fold Methods (<>) :: NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a # sconcat :: NonEmpty (NonEmptyDList a) -> NonEmptyDList a # stimes :: Integral b => b -> NonEmptyDList a -> NonEmptyDList a #