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

Safe Haskell | None
Language | Haskell2010

Optics.Internal.Indexed

Description

Internal implementation details of indexed optics.

This module is intended for internal use only, and may change without warning in subsequent releases.

Synopsis

- class is ~ NoIx => AcceptsEmptyIndices (f :: Symbol) (is :: IxList)
- class NonEmptyIndices (is :: IxList)
- class is ~ '[i] => HasSingleIndex (is :: IxList) i
- type family ShowTypes (types :: [Type]) :: ErrorMessage where ...
- data IntT (f :: k -> Type) (a :: k) = IntT !Int (f a)
- unIntT :: forall {k} f (a :: k). IntT f a -> f a
- newtype Indexing (f :: k -> Type) (a :: k) = Indexing {
  - runIndexing :: Int -> IntT f a
  }
- indexing :: forall {k} a f (b :: k) s (t :: k). ((a -> Indexing f b) -> s -> Indexing f t) -> (Int -> a -> f b) -> s -> f t
- conjoined :: forall (is :: IxList) i k s t a b. HasSingleIndex is i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b

# Documentation

class is ~ NoIx => AcceptsEmptyIndices (f :: Symbol) (is :: IxList) Source #

Show useful error message when a function expects optics without indices.

#### Instances

Instances details

AcceptsEmptyIndices f ('[] :: [Type]) Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError (('Text "\8216" ':<>: 'Text f) ':<>: 'Text "\8217 accepts only optics with no indices") :: Constraint, (x ': xs) ~ NoIx) => AcceptsEmptyIndices f (x ': xs) Source # |
Instance details Defined in Optics.Internal.Indexed

class NonEmptyIndices (is :: IxList) Source #

Check whether a list of indices is not empty and generate sensible error message if it's not.

#### Instances

Instances details

(TypeError ('Text "Indexed optic is expected") :: Constraint) => NonEmptyIndices ('[] :: [Type]) Source # |
Instance details Defined in Optics.Internal.Indexed
NonEmptyIndices (x ': xs) Source # |
Instance details Defined in Optics.Internal.Indexed

class is ~ '[i] => HasSingleIndex (is :: IxList) i Source #

Generate sensible error messages in case a user tries to pass either an unindexed optic or indexed optic with unflattened indices where indexed optic with a single index is expected.

#### Instances

Instances details

(TypeError ('Text "Indexed optic is expected") :: Constraint, ('[] :: [Type]) ~ '[i]) => HasSingleIndex ('[] :: [Type]) i Source # |
Instance details Defined in Optics.Internal.Indexed
HasSingleIndex '[i] i Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError ('Text "Use icomposeN to flatten indices of type " ':<>: ShowTypes is) :: Constraint, is ~ (i1 ': (i2 ': (i3 ': (i4 ': (i5 ': (i6 ': is')))))), is ~ '[i]) => HasSingleIndex (i1 ': (i2 ': (i3 ': (i4 ': (i5 ': (i6 ': is')))))) i Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError ('Text "Use icompose5 to flatten indices of type " ':<>: ShowTypes is) :: Constraint, is ~ '[i1, i2, i3, i4, i5], is ~ '[i]) => HasSingleIndex '[i1, i2, i3, i4, i5] i Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError ('Text "Use icompose4 to combine indices of type " ':<>: ShowTypes is) :: Constraint, is ~ '[i1, i2, i3, i4], is ~ '[i]) => HasSingleIndex '[i1, i2, i3, i4] i Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError ('Text "Use icompose3 to combine indices of type " ':<>: ShowTypes is) :: Constraint, is ~ '[i1, i2, i3], is ~ '[i]) => HasSingleIndex '[i1, i2, i3] i Source # |
Instance details Defined in Optics.Internal.Indexed
(TypeError ('Text "Use (<%>) or icompose to combine indices of type " ':<>: ShowTypes is) :: Constraint, is ~ '[i1, i2], is ~ '[i]) => HasSingleIndex '[i1, i2] i Source # |
Instance details Defined in Optics.Internal.Indexed

type family ShowTypes (types :: [Type]) :: ErrorMessage where ... Source #

Equations

ShowTypes '[i] = QuoteType i |
ShowTypes '[i, j] = (QuoteType i ':<>: 'Text " and ") ':<>: QuoteType j |
ShowTypes (i ': is) = (QuoteType i ':<>: 'Text ", ") ':<>: ShowTypes is |

data IntT (f :: k -> Type) (a :: k) Source #

Constructors

IntT !Int (f a) |

unIntT :: forall {k} f (a :: k). IntT f a -> f a Source #

newtype Indexing (f :: k -> Type) (a :: k) Source #

Constructors

Indexing |

Fields

- runIndexing :: Int -> IntT f a

#### Instances

Instances details

Applicative f => Applicative (Indexing f) Source # |
Instance details Defined in Optics.Internal.Indexed Methods pure :: a -> Indexing f a Source # (<*>) :: Indexing f (a -> b) -> Indexing f a -> Indexing f b Source # liftA2 :: (a -> b -> c) -> Indexing f a -> Indexing f b -> Indexing f c Source # (*>) :: Indexing f a -> Indexing f b -> Indexing f b Source # (<*) :: Indexing f a -> Indexing f b -> Indexing f a Source #
Functor f => Functor (Indexing f) Source # |
Instance details Defined in Optics.Internal.Indexed Methods fmap :: (a -> b) -> Indexing f a -> Indexing f b Source # (<$) :: a -> Indexing f b -> Indexing f a Source #

indexing :: forall {k} a f (b :: k) s (t :: k). ((a -> Indexing f b) -> s -> Indexing f t) -> (Int -> a -> f b) -> s -> f t Source #

Index a traversal by position of visited elements.

conjoined :: forall (is :: IxList) i k s t a b. HasSingleIndex is i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b Source #

Construct a conjoined indexed optic that provides a separate code path when used without indices. Useful for defining indexed optics that are as efficient as their unindexed equivalents when used without indices.

Note: ``conjoined` f g` is well-defined if and only if `f ≡ `noIx` g`.