lens-3.8.7.3: Lenses, Folds and Traversals

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

Control.Lens.Internal.Getter

Contents

- Internal Classes
  - Getters

Description

Synopsis

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

# Internal Classes

## Getters

class Functor f => Gettable f where

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

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

To ensure this, an instance of `Gettable` is required to satisfy:

    id = fmap f = coerce

Which is equivalent to making a ``Gettable` f` an "anyvariant" `Functor`.

Methods

coerce :: f a -> f b

Replace the phantom type argument.

Instances

Gettable (Const r) |
Gettable f => Gettable (Backwards f) |
Gettable (Accessor r) |
Gettable f => Gettable (Indexing64 f) |
Gettable f => Gettable (Indexing f) |
(Functor f, Gettable g) => Gettable (Compose f g) |
Gettable (Effect m r) |
(Profunctor p, Gettable g) => Gettable (PretextT p g a b) |
(Profunctor p, Gettable g) => Gettable (BazaarT p g a b) |
Gettable f => Gettable (TakingWhile p f a b) |
Gettable (EffectRWS w st m s) |

noEffect :: (Applicative f, Gettable f) => f a

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

newtype Accessor r a

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) |
Semigroup r => Apply (Accessor r) |
Gettable (Accessor r) |