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

Documentation

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

type family Size f :: Nat where ... Source #

Equations

Size (l :*: r) = Size l + Size r
Size (l :+: r) = Min ( Size l) ( Size r)
Size ( D1 meta f) = Size f
Size ( C1 meta f) = Size f
Size f = 1

type family CRep (a :: Type ) :: 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 t a b | 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 s t a b = (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]) (() :: Constraint )) Source #

type Context0 i 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]) (() :: Constraint )) Source #

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

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