lens-3.10: Lenses, Folds and Traversals

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

Control.Lens.Internal.Getter

Contents

- Internal Classes
  - Getters

Description

Synopsis

- class (Contravariant f, Functor f) => Gettable f
- coerce :: (Contravariant f, Functor f) => f a -> f b
- noEffect :: (Contravariant f, Applicative f) => f a
- newtype Accessor r a = Accessor {
  - runAccessor :: r
  }

# Internal Classes

class (Contravariant f, Functor f) => Gettable f Source

This class is provided mostly for backwards compatibility with lens 3.8, but it can also shorten type signatures.

Instances

(Contravariant f, Functor f) => Gettable f |

## Getters

coerce :: (Contravariant f, Functor f) => f a -> f bSource

This Generalizes `Const` so we can apply simple `Applicative` transformations to it and so we can get nicer error messages.

A `Functor` you can `coerce` ignores its argument, which it carries solely as a phantom type parameter.

By the `Functor` and `Contravariant` laws, an instance of `Gettable` will necessarily satisfy:

    id = fmap f = coerce = contramap g

noEffect :: (Contravariant f, Applicative f) => f aSource

The `mempty` equivalent for a `Gettable` `Applicative` `Functor`.

newtype Accessor r a Source

Used instead of `Const` to report

    No instance for (Settable Accessor)

when the user attempts to misuse a `Setter` as a `Getter`, rather than a monolithic unification error.

Constructors

Accessor |

Fields

runAccessor :: r

Instances

Effective Identity r (Accessor r) |
Functor (Accessor r) |
Monoid r => Applicative (Accessor r) |
Contravariant (Accessor r) |
Semigroup r => Apply (Accessor r) |