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

Safe Haskell | None
Language | Haskell2010

Optics.Internal.Optic.TypeLevel

Description

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

Synopsis

- type IxList = [Type]
- type NoIx = '[] :: [Type]
- type WithIx i = '[i]
- type family ShowSymbolWithOrigin (symbol :: Symbol) (origin :: Symbol) :: ErrorMessage where ...
- type family ShowSymbolsWithOrigin (fs :: [(Symbol, Symbol)]) :: ErrorMessage where ...
- type family ShowOperators (ops :: [Symbol]) :: ErrorMessage where ...
- type family AppendEliminations (a :: ([k], [k1])) (b :: ([k], [k1])) :: ([k], [k1]) where ...
- type family ShowEliminations (forms :: ([(Symbol, Symbol)], [Symbol])) :: ErrorMessage where ...
- type family Reverse (xs :: [k]) (acc :: [k]) :: [k] where ...
- type family Curry (xs :: IxList) y where ...
- type family Append (xs :: [k]) (ys :: [k]) :: [k] where ...
- class CurryCompose (xs :: IxList) where
  - composeN :: (i -> j) -> Curry xs i -> Curry xs j
- data IxEq (i :: k) (is :: k1) (js :: k1) where
  - IxEq :: forall {k} {k1} (i :: k) (is :: k1). IxEq i is is
- class AppendIndices (xs :: IxList) (ys :: IxList) (ks :: IxList) | xs ys -> ks where
  - appendIndices :: IxEq i (Curry xs (Curry ys i)) (Curry ks i)
- type family FirstRight (m1 :: Either e a) (m2 :: Either e a) :: Either e a where ...
- type family FromRight (def :: b) (e :: Either a b) :: b where ...
- type family IsLeft (e :: Either a b) :: Bool where ...
- type family When (p :: Bool) err where ...
- type family Unless (p :: Bool) err where ...
- type family Defined (f :: k) :: Bool where ...
- type family QuoteType (x :: t) :: ErrorMessage where ...
- type family QuoteSymbol (x :: Symbol) :: ErrorMessage where ...
- type family ToOrdinal (n :: Nat) :: ErrorMessage where ...
- class HasShapeOf (a :: k) (b :: k)

# Documentation

type IxList = [Type] Source #

A list of index types, used for indexed optics.

Since: 0.2

type NoIx = '[] :: [Type] Source #

An alias for an empty index-list

type WithIx i = '[i] Source #

Singleton index list

type family ShowSymbolWithOrigin (symbol :: Symbol) (origin :: Symbol) :: ErrorMessage where ... Source #

Equations

ShowSymbolWithOrigin symbol origin = ((('Text " " ':<>: QuoteSymbol symbol) ':<>: 'Text " (from ") ':<>: 'Text origin) ':<>: 'Text ")" |

type family ShowSymbolsWithOrigin (fs :: [(Symbol, Symbol)]) :: ErrorMessage where ... Source #

Equations

ShowSymbolsWithOrigin '['(symbol, origin)] = ShowSymbolWithOrigin symbol origin |
ShowSymbolsWithOrigin ('(symbol, origin) ': rest) = ShowSymbolWithOrigin symbol origin ':$$: ShowSymbolsWithOrigin rest |

type family ShowOperators (ops :: [Symbol]) :: ErrorMessage where ... Source #

Equations

ShowOperators '[op] = QuoteSymbol op ':<>: 'Text " (from Optics.Operators)" |
ShowOperators (op ': rest) = (QuoteSymbol op ':<>: 'Text " ") ':<>: ShowOperators rest |

type family AppendEliminations (a :: ([k], [k1])) (b :: ([k], [k1])) :: ([k], [k1]) where ... Source #

Equations

AppendEliminations ('(fs1, ops1) :: ([k1], [k2])) ('(fs2, ops2) :: ([k1], [k2])) = '(Append fs1 fs2, Append ops1 ops2) |

type family ShowEliminations (forms :: ([(Symbol, Symbol)], [Symbol])) :: ErrorMessage where ... Source #

Equations

ShowEliminations '(fs, ops) = ShowSymbolsWithOrigin fs ':$$: ('Text " " ':<>: ShowOperators ops) |

type family Reverse (xs :: [k]) (acc :: [k]) :: [k] where ... Source #

Reverse a type-level list.

Equations

Reverse ('[] :: [k]) (acc :: [k]) = acc |
Reverse (x ': xs :: [a]) (acc :: [a]) = Reverse xs (x ': acc) |

type family Curry (xs :: IxList) y where ... Source #

Curry a type-level list.

In pseudo (dependent-)Haskell:

    Curry xs y = foldr (->) y xs

Equations

Curry ('[] :: [Type]) y = y |
Curry (x ': xs) y = x -> Curry xs y |

type family Append (xs :: [k]) (ys :: [k]) :: [k] where ... Source #

Append two type-level lists together.

Equations

Append ('[] :: [k]) (ys :: [k]) = ys |
Append (xs :: [k]) ('[] :: [k]) = xs |
Append (x ': xs :: [k]) (ys :: [k]) = x ': Append xs ys |

class CurryCompose (xs :: IxList) where Source #

Class that is inhabited by all type-level lists `xs`, providing the ability to compose a function under ``Curry` xs`.

Methods

composeN :: (i -> j) -> Curry xs i -> Curry xs j Source #

Compose a function under ``Curry` xs`. This generalises `(`.`)` (aka `fmap` for `(->)`) to work for curried functions with one argument for each type in the list.

#### Instances

Instances details

CurryCompose ('[] :: [Type]) Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel Methods composeN :: (i -> j) -> Curry ('[] :: [Type]) i -> Curry ('[] :: [Type]) j Source #
CurryCompose xs => CurryCompose (x ': xs) Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel Methods composeN :: (i -> j) -> Curry (x ': xs) i -> Curry (x ': xs) j Source #

data IxEq (i :: k) (is :: k1) (js :: k1) where Source #

Tagged version of 'Data.Type.Equality.(:~:)' for carrying evidence that two index lists in a curried form are equal.

Constructors

IxEq :: forall {k} {k1} (i :: k) (is :: k1). IxEq i is is |

class AppendIndices (xs :: IxList) (ys :: IxList) (ks :: IxList) | xs ys -> ks where Source #

In pseudo (dependent-)Haskell, provide a witness

    foldr f (foldr f init xs) ys = foldr f init (ys ++ xs)
       where f = (->)

Since: 0.4

Methods

appendIndices :: IxEq i (Curry xs (Curry ys i)) (Curry ks i) Source #

#### Instances

Instances details

xs ~ zs => AppendIndices xs ('[] :: [Type]) zs Source # | If the second list is empty, we can pick the first list even if nothing is known about it.
Instance details Defined in Optics.Internal.Optic.TypeLevel Methods appendIndices :: IxEq i (Curry xs (Curry ('[] :: [Type]) i)) (Curry zs i) Source #
ys ~ zs => AppendIndices ('[] :: [Type]) ys zs Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel Methods appendIndices :: IxEq i (Curry ('[] :: [Type]) (Curry ys i)) (Curry zs i) Source #
AppendIndices xs ys ks => AppendIndices (x ': xs) ys (x ': ks) Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel Methods appendIndices :: IxEq i (Curry (x ': xs) (Curry ys i)) (Curry (x ': ks) i) Source #

type family FirstRight (m1 :: Either e a) (m2 :: Either e a) :: Either e a where ... Source #

If lhs is `Right`, return it. Otherwise check rhs.

Equations

FirstRight ('Right a :: Either e b) (_1 :: Either e b) = 'Right a :: Either e b |
FirstRight (_1 :: Either e a) (b :: Either e a) = b |

type family FromRight (def :: b) (e :: Either a b) :: b where ... Source #

Equations

FromRight (_1 :: b1) ('Right b2 :: Either a b1) = b2 |
FromRight (def :: b) ('Left _1 :: Either a b) = def |

type family IsLeft (e :: Either a b) :: Bool where ... Source #

Equations

IsLeft ('Left _1 :: Either a b) = 'True |
IsLeft ('Right _1 :: Either a b) = 'False |

type family When (p :: Bool) err where ... Source #

Show a custom type error if `p` is true.

Equations

When 'True err = err |
When 'False _1 = () |

type family Unless (p :: Bool) err where ... Source #

Show a custom type error if `p` is false (or stuck).

Equations

Unless 'True _1 = () |
Unless 'False err = err |

type family Defined (f :: k) :: Bool where ... Source #

Use with `Unless` to detect stuck (undefined) type families.

Equations

Defined (f _1 :: k2) = Defined f |
Defined (_1 :: k) = 'True |

type family QuoteType (x :: t) :: ErrorMessage where ... Source #

Show a type surrounded by quote marks.

Equations

QuoteType (x :: t) = ('Text "\8216" ':<>: 'ShowType x) ':<>: 'Text "\8217" |

type family QuoteSymbol (x :: Symbol) :: ErrorMessage where ... Source #

Show a symbol surrounded by quote marks.

Equations

QuoteSymbol x = ('Text "\8216" ':<>: 'Text x) ':<>: 'Text "\8217" |

type family ToOrdinal (n :: Nat) :: ErrorMessage where ... Source #

Equations

ToOrdinal 1 = 'Text "1st" |
ToOrdinal 2 = 'Text "2nd" |
ToOrdinal 3 = 'Text "3rd" |
ToOrdinal n = 'ShowType n ':<>: 'Text "th" |

class HasShapeOf (a :: k) (b :: k) Source #

Derive the shape of `a` from the shape of `b`.

#### Instances

Instances details

a ~ b => HasShapeOf (a :: k) (b :: k) Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel
(fa ~ f a, HasShapeOf f g) => HasShapeOf (fa :: k1) (g b :: k1) Source # |
Instance details Defined in Optics.Internal.Optic.TypeLevel