Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 :: OpticKind
- getting :: 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.
type ReadOnlyOptic k :: OpticKind Source #
getting :: 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 ::
of read-write
kind
Optic
k is s t a b
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