generic-lens-core-2.2.1.0: Generically derive traversals, lenses and prisms.

Copyright | (C) 2020 Csongor Kiss
License | BSD3
Maintainer | Csongor Kiss <kiss.csongor.kiss@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell2010

Data.Generics.Product.Internal.Positions

Description

Derive positional product type getters and setters generically.

Synopsis

- type (<?) (x :: k) (y :: k) = Not (y <=? x)
- type family Size (f :: k -> Type) :: Nat where ...
- type family CRep a :: G where ...
- class Context (i :: Nat) (s :: k) (t :: k1) (a :: k2) (b :: k3) | s i -> a, t i -> b, s i b -> t, t i a -> s
- type Context_ (i :: Nat) s t (a :: k) (b :: k1) = (ErrorUnless i s ((0 <? i) && (i <=? Size (Rep s))), UnifyHead s t, UnifyHead t s)
- type Context' (i :: Nat) s a = (Generic s, ErrorUnless i s ((0 <? i) && (i <=? Size (Rep s))), Coercible (Rep s) (CRep s), GLens' (HasTotalPositionPSym i) (CRep s) a, Defined (Rep s) (NoGeneric s '['Text "arising from a generic lens focusing on the field at", (((('Text "position " ':<>: QuoteType i) ':<>: 'Text " of type ") ':<>: QuoteType a) ':<>: 'Text " in ") ':<>: QuoteType s]) ())
- type Context0 (i :: Nat) s t a b = (Generic s, Generic t, GLens (HasTotalPositionPSym i) (CRep s) (CRep t) a b, Coercible (CRep s) (Rep s), Coercible (CRep t) (Rep t), Defined (Rep s) (NoGeneric s '['Text "arising from a generic lens focusing on the field at", (((('Text "position " ':<>: QuoteType i) ':<>: 'Text " of type ") ':<>: QuoteType a) ':<>: 'Text " in ") ':<>: QuoteType s]) ())
- derived0 :: forall (i :: Nat) s t a b. Context0 i s t a b => Lens s t a b
- derived' :: forall (i :: Nat) s a. Context' i s a => Lens s s a a

# Documentation

type (<?) (x :: k) (y :: k) = Not (y <=? x) infixl 4 Source #

type family Size (f :: k -> Type) :: Nat where ... Source #

Equations

Size (l :*: r :: k -> Type) = Size l + Size r |
Size (l :+: r :: k -> Type) = Min (Size l) (Size r) |
Size (D1 meta f :: k -> Type) = Size f |
Size (C1 meta f :: k -> Type) = Size f |
Size (f :: k -> Type) = 1 |

type family CRep a :: G where ... Source #

In-order labeling of the generic tree with the field positions

We replace the (K1 R a) nodes with (K1 (Pos n) a), where `n` is the position of the field in question in the data type. This is convenient, because we can reuse all the existing functions as long as they are polymorphic in the first parameter of `K1`.

Equations

CRep rep = Fst (Traverse (Rep rep) 1) |

class Context (i :: Nat) (s :: k) (t :: k1) (a :: k2) (b :: k3) | s i -> a, t i -> b, s i b -> t, t i a -> s Source #

#### Instances

Instances details

(ErrorUnless i s ((0 <? i) && (i <=? Size (Rep s))), HasTotalPositionP i (CRep s) ~ 'Just a, HasTotalPositionP i (CRep t) ~ 'Just b, HasTotalPositionP i (CRep (Indexed s)) ~ 'Just a', HasTotalPositionP i (CRep (Indexed t)) ~ 'Just b', t ~ Infer s a' b, s ~ Infer t b' a) => Context i (s :: Type) (t :: Type) (a :: Type) (b :: Type) Source # |
Instance details Defined in Data.Generics.Product.Internal.Positions

type Context_ (i :: Nat) s t (a :: k) (b :: k1) = (ErrorUnless i s ((0 <? i) && (i <=? Size (Rep s))), UnifyHead s t, UnifyHead t s) Source #

type Context' (i :: Nat) s a = (Generic s, ErrorUnless i s ((0 <? i) && (i <=? Size (Rep s))), Coercible (Rep s) (CRep s), GLens' (HasTotalPositionPSym i) (CRep s) a, Defined (Rep s) (NoGeneric s '['Text "arising from a generic lens focusing on the field at", (((('Text "position " ':<>: QuoteType i) ':<>: 'Text " of type ") ':<>: QuoteType a) ':<>: 'Text " in ") ':<>: QuoteType s]) ()) Source #

type Context0 (i :: Nat) s t a b = (Generic s, Generic t, GLens (HasTotalPositionPSym i) (CRep s) (CRep t) a b, Coercible (CRep s) (Rep s), Coercible (CRep t) (Rep t), Defined (Rep s) (NoGeneric s '['Text "arising from a generic lens focusing on the field at", (((('Text "position " ':<>: QuoteType i) ':<>: 'Text " of type ") ':<>: QuoteType a) ':<>: 'Text " in ") ':<>: QuoteType s]) ()) Source #

derived0 :: forall (i :: Nat) s t a b. Context0 i s t a b => Lens s t a b Source #

derived' :: forall (i :: Nat) s a. Context' i s a => Lens s s a a Source #