optics-core-0.4.1.1: Optics as an abstract interface: core definitions

Safe Haskell | None
Language | Haskell2010

Optics.ReadOnly

Description

This module defines `getting`, which turns a read-write optic into its read-only counterpart.

Synopsis

- class ToReadOnly k s t a b where
  - type ReadOnlyOptic k
  - getting :: forall (is :: IxList). Optic k is s t a b -> Optic' (ReadOnlyOptic k) is s a

# Documentation

class ToReadOnly k s t a b where Source #

Class for read-write optics that have their read-only counterparts.

Associated Types

type ReadOnlyOptic k Source #

Methods

getting :: forall (is :: IxList). Optic k is s t a b -> Optic' (ReadOnlyOptic k) is s a Source #

Turn read-write optic into its read-only counterpart (or leave read-only optics as-is).

This is useful when you have an `optic :: `Optic` k is s t a b` of read-write kind `k` such that `s`, `t`, `a`, `b` are rigid, there is no evidence that `s ~ t` and `a ~ b` and you want to pass `optic` to one of the functions that accept read-only optic kinds.

Example:

    >>> let fstIntToChar = _1 :: Lens (Int, r) (Char, r) Int Char

    >>> :t view fstIntToChar
    ...
    ...Couldn't match type ‘Char’ with ‘Int’
    ...

    >>> :t view (getting fstIntToChar)
    view (getting fstIntToChar) :: (Int, r) -> Int

#### Instances

Instances details

(s ~ t, a ~ b) => ToReadOnly A_Fold s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Fold |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_Fold = A_Fold

Methods

getting :: forall (is :: IxList). Optic A_Fold is s t a b -> Optic' (ReadOnlyOptic A_Fold) is s a Source #

(s ~ t, a ~ b) => ToReadOnly A_Getter s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Getter |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_Getter = A_Getter

Methods

getting :: forall (is :: IxList). Optic A_Getter is s t a b -> Optic' (ReadOnlyOptic A_Getter) is s a Source #

ToReadOnly A_Lens s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Lens |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_Lens = A_Getter

Methods

getting :: forall (is :: IxList). Optic A_Lens is s t a b -> Optic' (ReadOnlyOptic A_Lens) is s a Source #

ToReadOnly A_Prism s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Prism |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_Prism = An_AffineFold

Methods

getting :: forall (is :: IxList). Optic A_Prism is s t a b -> Optic' (ReadOnlyOptic A_Prism) is s a Source #

ToReadOnly A_ReversedPrism s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_ReversedPrism |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_ReversedPrism = A_Getter

Methods

getting :: forall (is :: IxList). Optic A_ReversedPrism is s t a b -> Optic' (ReadOnlyOptic A_ReversedPrism) is s a Source #

ToReadOnly A_Traversal s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Traversal |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic A_Traversal = A_Fold

Methods

getting :: forall (is :: IxList). Optic A_Traversal is s t a b -> Optic' (ReadOnlyOptic A_Traversal) is s a Source #

(s ~ t, a ~ b) => ToReadOnly An_AffineFold s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic An_AffineFold |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic An_AffineFold = An_AffineFold

Methods

getting :: forall (is :: IxList). Optic An_AffineFold is s t a b -> Optic' (ReadOnlyOptic An_AffineFold) is s a Source #

ToReadOnly An_AffineTraversal s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic An_AffineTraversal |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic An_AffineTraversal = An_AffineFold

Methods

getting :: forall (is :: IxList). Optic An_AffineTraversal is s t a b -> Optic' (ReadOnlyOptic An_AffineTraversal) is s a Source #

ToReadOnly An_Iso s t a b Source # |

Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic An_Iso |
Instance details Defined in Optics.ReadOnly type ReadOnlyOptic An_Iso = A_Getter

Methods

getting :: forall (is :: IxList). Optic An_Iso is s t a b -> Optic' (ReadOnlyOptic An_Iso) is s a Source #