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

Data.Generics.Product.Internal.Types

Synopsis

Documentation

type family Children ch a :: [Type] #

The children of a type are the types of its fields. The Children type family maps a type a to its set of children.

This type family is parameterized by a symbol ch (that can be declared as an empty data type). The symbol ChGeneric provides a default definition. You can create new symbols to override the set of children of abstract, non-generic types.

The following example declares a Custom symbol to redefine Children for some abstract types from the time library.

data Custom
type instance Children Custom a = ChildrenCustom a

type family ChildrenCustom (a :: Type) where
  ChildrenCustom DiffTime        = '[]
  ChildrenCustom NominalDiffTime = '[]
  -- Add more custom mappings here.

  ChildrenCustom a = Children ChGeneric a

To use this definition, replace types with typesUsing @Custom.

Instances

Instances details
type Children ChGeneric a # 
Instance details

Defined in Data.Generics.Product.Internal.Types

data ChGeneric #

The default definition of Children. Primitive types from core libraries have no children, and other types are assumed to be Generic.

Instances

Instances details
HasTypes b a => GHasTypes ChGeneric (Rec0 b :: k -> Type) (Rec0 b :: k -> Type) a a #

The default instance for HasTypes acts as a synonym for 'HasTypesUsing ChGeneric', so in most cases this instance should behave the same as the one above. However, there might be overlapping instances defined for HasTypes directly, in which case we want to prefer those instances (even though the custom instances should always be added to HasTypesCustom)

Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k). Traversal (Rec0 b x) (Rec0 b x) a a #

type Children ChGeneric a # 
Instance details

Defined in Data.Generics.Product.Internal.Types

type family ChildrenDefault a :: [Type] where ... #

Equations

ChildrenDefault Char = '[] :: [Type] 
ChildrenDefault Double = '[] :: [Type] 
ChildrenDefault Float = '[] :: [Type] 
ChildrenDefault Integer = '[] :: [Type] 
ChildrenDefault Int = '[] :: [Type] 
ChildrenDefault Int8 = '[] :: [Type] 
ChildrenDefault Int16 = '[] :: [Type] 
ChildrenDefault Int32 = '[] :: [Type] 
ChildrenDefault Int64 = '[] :: [Type] 
ChildrenDefault Word = '[] :: [Type] 
ChildrenDefault Word8 = '[] :: [Type] 
ChildrenDefault Word16 = '[] :: [Type] 
ChildrenDefault Word32 = '[] :: [Type] 
ChildrenDefault Word64 = '[] :: [Type] 
ChildrenDefault Text = '[] :: [Type] 
ChildrenDefault (Param n _1) = '[] :: [Type] 
ChildrenDefault a = Defined (Rep a) (NoGeneric a '['Text "arising from a generic traversal.", 'Text "Either derive the instance, or define a custom traversal using HasTypesCustom"]) (ChildrenGeneric (Rep a) ('[] :: [Type])) 

type family ChildrenGeneric (f :: k -> Type) (cs :: [Type]) :: [Type] where ... #

Equations

ChildrenGeneric (M1 _1 _2 f :: k -> Type) cs = ChildrenGeneric f cs 
ChildrenGeneric (l :*: r :: k -> Type) cs = ChildrenGeneric l (ChildrenGeneric r cs) 
ChildrenGeneric (l :+: r :: k -> Type) cs = ChildrenGeneric l (ChildrenGeneric r cs) 
ChildrenGeneric (Rec0 a :: k -> Type) cs = a ': cs 
ChildrenGeneric (_1 :: k -> Type) cs = cs 

type Interesting ch a t = Defined_list (Children ch t) (NoChildren ch t) (IsNothing (Interesting' ch a '[t] (Children ch t))) #

type family NoChildren ch a where ... #

Equations

NoChildren ch a = PrettyError '['Text "No type family instance for " ':<>: QuoteType (Children ch a), 'Text "arising from a traversal over " ':<>: QuoteType a, 'Text "with custom strategy " ':<>: QuoteType ch] :: Constraint 

type family Interesting' ch a (seen :: [Type]) (ts :: [Type]) :: Maybe [Type] where ... #

Equations

Interesting' ch _1 seen ('[] :: [Type]) = 'Just seen 
Interesting' ch a seen (t ': ts) = InterestingOr ch a (InterestingUnless ch a seen t (Elem t seen)) ts 

type family InterestingUnless ch a (seen :: [Type]) t (alreadySeen :: Bool) :: Maybe [Type] where ... #

Equations

InterestingUnless ch a seen a _1 = 'Nothing :: Maybe [Type] 
InterestingUnless ch a seen t 'True = 'Just seen 
InterestingUnless ch a seen t 'False = Defined_list (Children ch t) (NoChildren ch t) (Interesting' ch a (t ': seen) (Children ch t)) 

type family InterestingOr ch a (seen' :: Maybe [Type]) (ts :: [Type]) :: Maybe [Type] where ... #

Equations

InterestingOr ch a ('Nothing :: Maybe [Type]) _1 = 'Nothing :: Maybe [Type] 
InterestingOr ch a ('Just seen) ts = Interesting' ch a seen ts 

type family Elem (a1 :: a) (as :: [a]) :: Bool where ... #

Equations

Elem (a2 :: a1) (a2 ': _1 :: [a1]) = 'True 
Elem (a2 :: a1) (_1 ': as :: [a1]) = Elem a2 as 
Elem (a2 :: a1) ('[] :: [a1]) = 'False 

type family IsNothing (a1 :: Maybe a) :: Bool where ... #

Equations

IsNothing ('Just _1 :: Maybe a) = 'False 
IsNothing ('Nothing :: Maybe a) = 'True 

class HasTypes s a where #

Minimal complete definition

Nothing

Methods

types_ :: Traversal' s a #

Instances

Instances details
HasTypes Void a # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

types_ :: Traversal' Void a #

HasTypes s Void # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

types_ :: Traversal' s Void #

HasTypesUsing ChGeneric s s a a => HasTypes s a # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

types_ :: Traversal' s a #

data Void #

Instances

Instances details
HasTypes Void a # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

types_ :: Traversal' Void a #

HasTypes s Void # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

types_ :: Traversal' s Void #

HasTypesUsing ch Void Void a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal Void Void a b #

HasTypesUsing ch s s Void Void # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal s s Void Void #

class HasTypesUsing ch s t a b where #

Since: 1.2.0.0

Methods

typesUsing_ :: Traversal s t a b #

Instances

Instances details
HasTypesUsing ch Void Void a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal Void Void a b #

HasTypesUsing ch a b a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal a b a b #

HasTypesUsing ch s s Void Void # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal s s Void Void #

HasTypesOpt ch (Interesting ch a s) s t a b => HasTypesUsing ch s t a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesUsing_ :: Traversal s t a b #

class HasTypesCustom ch s t a b where #

By adding instances to this class, we can override the default behaviour in an ad-hoc manner. For example:

instance HasTypesCustom Custom Opaque Opaque String String where
  typesCustom f (Opaque str) = Opaque $ f str

Since: 1.2.0.0

Methods

typesCustom :: Traversal s t a b #

This function should never be used directly, only to override the default traversal behaviour. To actually use the custom traversal strategy, see typesUsing. This is because typesUsing does additional optimisations, like ensuring that nodes with no relevant members will not be traversed at runtime.

Instances

Instances details
(GHasTypes ch (Rep s) (Rep t) a b, Generic s, Generic t, Defined (Rep s) (PrettyError '['Text "No instance " ':<>: QuoteType (HasTypesCustom ch s t a b)] :: Constraint) ()) => HasTypesCustom ch s t a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesCustom :: Traversal s t a b #

class HasTypesOpt ch (p :: Bool) s t a b where #

Methods

typesOpt :: Traversal s t a b #

Instances

Instances details
HasTypesOpt ch 'False s s a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesOpt :: Traversal s s a b #

HasTypesCustom ch s t a b => HasTypesOpt ch 'True s t a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

typesOpt :: Traversal s t a b #

class GHasTypes (ch :: k) (s :: k1 -> Type) (t :: k1 -> Type) a b where #

Methods

gtypes_ :: forall (x :: k1). Traversal (s x) (t x) a b #

Instances

Instances details
GHasTypes (ch :: k1) (U1 :: k2 -> Type) (U1 :: k2 -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k2). Traversal (U1 x) (U1 x) a b #

GHasTypes (ch :: k1) (V1 :: k2 -> Type) (V1 :: k2 -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k2). Traversal (V1 x) (V1 x) a b #

HasTypes b a => GHasTypes ChGeneric (Rec0 b :: k -> Type) (Rec0 b :: k -> Type) a a #

The default instance for HasTypes acts as a synonym for 'HasTypesUsing ChGeneric', so in most cases this instance should behave the same as the one above. However, there might be overlapping instances defined for HasTypes directly, in which case we want to prefer those instances (even though the custom instances should always be added to HasTypesCustom)

Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k). Traversal (Rec0 b x) (Rec0 b x) a a #

HasTypesUsing ch s t a b => GHasTypes (ch :: Type) (Rec0 s :: k -> Type) (Rec0 t :: k -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k). Traversal (Rec0 s x) (Rec0 t x) a b #

(GHasTypes ch l l' a b, GHasTypes ch r r' a b) => GHasTypes (ch :: k1) (l :*: r :: k2 -> Type) (l' :*: r' :: k2 -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k2). Traversal ((l :*: r) x) ((l' :*: r') x) a b #

(GHasTypes ch l l' a b, GHasTypes ch r r' a b) => GHasTypes (ch :: k1) (l :+: r :: k2 -> Type) (l' :+: r' :: k2 -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k2). Traversal ((l :+: r) x) ((l' :+: r') x) a b #

GHasTypes ch s t a b => GHasTypes (ch :: k1) (M1 m meta s :: k2 -> Type) (M1 m meta t :: k2 -> Type) a b # 
Instance details

Defined in Data.Generics.Product.Internal.Types

Methods

gtypes_ :: forall (x :: k2). Traversal (M1 m meta s x) (M1 m meta t x) a b #