| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Optic.Getter
Contents
Synopsis
- type Getter s a = forall (f :: * -> *). (Contravariant f, Functor f) => (a -> f a) -> s -> f s
- to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a
Getter
type Getter s a = forall (f :: * -> *). (Contravariant f, Functor f) => (a -> f a) -> s -> f s #
A Getter describes how to retrieve a single value in a way that can be
composed with other LensLike constructions.
Unlike a Lens a Getter is read-only. Since a Getter
cannot be used to write back there are no Lens laws that can be applied to
it. In fact, it is isomorphic to an arbitrary function from (s -> a).
Moreover, a Getter can be used directly as a Fold,
since it just ignores the Applicative.
to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a #