HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleoptics-core-0.4.1.1Haskell2010

Optics.ReadOnly

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

  • 1 class
classclass ToReadOnly (k :: OpticKind) s t a b where
#

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

Associated types

Methods

  • getting :: Optic k is s t a b -> Optic' (ReadOnlyOptic k) is s a

    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:

    Example1 expression
    let fstIntToChar = _1 :: Lens (Int, r) (Char, r) Int Char
    Example1 expression
    :t view fstIntToChar......Couldn't match type ‘Char’ with ‘Int’...
    Example1 expression
    :t view (getting fstIntToChar)view (getting fstIntToChar) :: (Int, r) -> Int
Instances9ToReadOnly, …