Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.Record.Generic
Synopsis
- class Generic a where
- type Constraints a :: (Type -> Constraint) -> Constraint
- type MetadataOf a :: [(Symbol, Type)]
- from :: a -> Rep I a
- to :: Rep I a -> a
- dict :: Constraints a c => Proxy c -> Rep (Dict c) a
- metadata :: proxy a -> Metadata a
- newtype Rep f a = Rep (SmallArray (f Any))
- data Metadata a = Metadata {}
- data FieldStrictness
- recordFieldNames :: Metadata a -> Rep (K String) a
- data FieldMetadata x where
- FieldMetadata :: KnownSymbol name => Proxy name -> FieldStrictness -> FieldMetadata x
- type family FieldName (field :: (Symbol, Type)) :: Symbol where ...
- type family FieldType (field :: (Symbol, Type)) :: Type where ...
- class (field ~ '(FieldName field, FieldType field), KnownSymbol (FieldName field)) => IsField field
- data Dict (c :: k -> Constraint) (a :: k) where
- Dict :: forall {k} (c :: k -> Constraint) (a :: k). c a => Dict c a
- newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) = Comp (f (g p))
- newtype I a = I a
- newtype K a (b :: k) = K a
- unK :: forall {k} a (b :: k). K a b -> a
- unI :: I a -> a
- unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p)
- mapII :: (a -> b) -> I a -> I b
- mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c
- mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b
- mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d
- mapIII :: (a -> b -> c) -> I a -> I b -> I c
- mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d
- mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c
- mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e
- mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c
- mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e
- mapKKI :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> K b e -> I c
- mapKKK :: forall {k1} {k2} {k3} a b c (d :: k1) (e :: k2) (f :: k3). (a -> b -> c) -> K a d -> K b e -> K c f
- newtype ((f :: k -> Type) -.-> (g :: k -> Type)) (a :: k) = Fn {
- apFn :: f a -> g a
- data Proxy (t :: k) = Proxy
Types with a generic view
class Generic a where Source #
Associated Types
type Constraints a :: (Type -> Constraint) -> Constraint Source #
Constraints a c
means "all fields of a
satisfy c
"
type MetadataOf a :: [(Symbol, Type)] Source #
Type-level metadata
NOTE: using type-level lists without resulting in quadratic core code is extremely difficult. Any use of this type-level metadata therefore needs delibrate consideration. Some examples:
o Within the large-generics
library, MetadataOf
is used in the
definition of HasNormalForm
. This constraint is carefully defined to
avoid quadratic code, as described in the presentation
"Avoiding Quadratic Blow-up During Compilation"
https://skillsmatter.com/skillscasts/17262-avoiding-quadratic-blow-up-during-compilation
o The large-records
library uses it to provide a compatibility layer
between it and sop-core
; this is however only for testing purposes, and
the quadratic code here is simply accepted.
Representation of some record a
The f
parameter describes which functor has been applied to all fields of
the record; in other words Rep I
is isomorphic to the record itself.
Constructors
Rep (SmallArray (f Any)) |
Metadata
Constructors
Metadata | |
Fields
|
data FieldStrictness Source #
Constructors
FieldStrict | |
FieldLazy |
data FieldMetadata x where Source #
Constructors
FieldMetadata :: KnownSymbol name => Proxy name -> FieldStrictness -> FieldMetadata x |
Working with type-level metadata
type family FieldName (field :: (Symbol, Type)) :: Symbol where ... Source #
Equations
FieldName '(name, _typ) = name |
type family FieldType (field :: (Symbol, Type)) :: Type where ... Source #
Equations
FieldType '(_name, typ) = typ |
class (field ~ '(FieldName field, FieldType field), KnownSymbol (FieldName field)) => IsField field Source #
Instances
(field ~ '(FieldName field, FieldType field), KnownSymbol (FieldName field)) => IsField field Source # | |
Defined in Data.Record.Generic |
Re-exports
data Dict (c :: k -> Constraint) (a :: k) where #
An explicit dictionary carrying evidence of a class constraint.
The constraint parameter is separated into a
second argument so that
is of the correct
kind to be used directly as a parameter to e.g. Dict
cNP
.
Since: sop-core-0.2
Constructors
Dict :: forall {k} (c :: k -> Constraint) (a :: k). c a => Dict c a |
newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) infixr 7 #
Composition of functors.
Like Compose
, but kind-polymorphic
and with a shorter name.
Constructors
Comp (f (g p)) |
Instances
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # | |
(Eq1 f, Eq1 g) => Eq1 (f :.: g) | Since: sop-core-0.2.4.0 |
(Ord1 f, Ord1 g) => Ord1 (f :.: g) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Read1 f, Read1 g) => Read1 (f :.: g) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Show1 f, Show1 g) => Show1 (f :.: g) | Since: sop-core-0.2.4.0 |
(Traversable f, Traversable g) => Traversable (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: sop-core-0.2.5.0 |
(Functor f, Functor g) => Functor (f :.: g) | |
(NFData1 f, NFData1 g) => NFData1 (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Monoid (f (g x)) => Monoid ((f :.: g) x) | Since: sop-core-0.4.0.0 |
Semigroup (f (g x)) => Semigroup ((f :.: g) x) | Since: sop-core-0.4.0.0 |
Generic ((f :.: g) p) | |
(Read1 f, Read1 g, Read a) => Read ((f :.: g) a) | |
(Show1 f, Show1 g, Show a) => Show ((f :.: g) a) | |
NFData (f (g a)) => NFData ((f :.: g) a) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Eq1 f, Eq1 g, Eq a) => Eq ((f :.: g) a) | |
(Ord1 f, Ord1 g, Ord a) => Ord ((f :.: g) a) | |
Defined in Data.SOP.BasicFunctors | |
type Rep ((f :.: g) p) | |
Defined in Data.SOP.BasicFunctors | |
type Code ((f :.: g) p) | |
Defined in Generics.SOP.Instances | |
type DatatypeInfoOf ((f :.: g) p) | |
Defined in Generics.SOP.Instances |
The identity type functor.
Like Identity
, but with a shorter name.
Constructors
I a |
Instances
Foldable I | |
Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => I m -> m # foldMap :: Monoid m => (a -> m) -> I a -> m # foldMap' :: Monoid m => (a -> m) -> I a -> m # foldr :: (a -> b -> b) -> b -> I a -> b # foldr' :: (a -> b -> b) -> b -> I a -> b # foldl :: (b -> a -> b) -> b -> I a -> b # foldl' :: (b -> a -> b) -> b -> I a -> b # foldr1 :: (a -> a -> a) -> I a -> a # foldl1 :: (a -> a -> a) -> I a -> a # elem :: Eq a => a -> I a -> Bool # maximum :: Ord a => I a -> a # | |
Eq1 I | Since: sop-core-0.2.4.0 |
Ord1 I | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read1 I | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Show1 I | Since: sop-core-0.2.4.0 |
Traversable I | |
Applicative I | |
Functor I | |
Monad I | |
NFData1 I | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Monoid a => Monoid (I a) | Since: sop-core-0.4.0.0 |
Semigroup a => Semigroup (I a) | Since: sop-core-0.4.0.0 |
Generic (I a) | |
Read a => Read (I a) | |
Show a => Show (I a) | |
NFData a => NFData (I a) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (I a) | |
Ord a => Ord (I a) | |
type Rep (I a) | |
Defined in Data.SOP.BasicFunctors | |
type Code (I a) | |
Defined in Generics.SOP.Instances | |
type DatatypeInfoOf (I a) | |
Defined in Generics.SOP.Instances |
The constant type functor.
Like Constant
, but kind-polymorphic
in its second argument and with a shorter name.
Constructors
K a |
Instances
Eq2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Ord2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (K a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [K a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (K a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [K a b] # | |
Show2 (K :: Type -> TYPE LiftedRep -> Type) | Since: sop-core-0.2.4.0 |
NFData2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Foldable (K a :: TYPE LiftedRep -> Type) | |
Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => K a m -> m # foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> K a a0 -> m # foldr :: (a0 -> b -> b) -> b -> K a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b # foldl :: (b -> a0 -> b) -> b -> K a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # elem :: Eq a0 => a0 -> K a a0 -> Bool # maximum :: Ord a0 => K a a0 -> a0 # minimum :: Ord a0 => K a a0 -> a0 # | |
Eq a => Eq1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Ord a => Ord1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read a => Read1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Show a => Show1 (K a :: TYPE LiftedRep -> Type) | Since: sop-core-0.2.4.0 |
Traversable (K a :: TYPE LiftedRep -> Type) | |
Monoid a => Applicative (K a :: Type -> Type) | |
Functor (K a :: TYPE LiftedRep -> Type) | |
Show x => Show (Rep (K x :: Type -> Type) a) Source # | |
NFData a => NFData1 (K a :: TYPE LiftedRep -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq x => Eq (Rep (K x :: Type -> Type) a) Source # | |
Monoid a => Monoid (K a b) | Since: sop-core-0.4.0.0 |
Semigroup a => Semigroup (K a b) | Since: sop-core-0.4.0.0 |
Generic (K a b) | |
Read a => Read (K a b) | |
Show a => Show (K a b) | |
NFData a => NFData (K a b) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (K a b) | |
Ord a => Ord (K a b) | |
type Rep (K a b) | |
Defined in Data.SOP.BasicFunctors | |
type Code (K a b) | |
Defined in Generics.SOP.Instances | |
type DatatypeInfoOf (K a b) | |
Defined in Generics.SOP.Instances |
unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p) #
Extract the contents of a Comp
value.
mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c #
Lift the given function.
Since: sop-core-0.2.5.0
mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b #
Lift the given function.
Since: sop-core-0.2.5.0
mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d #
Lift the given function.
Since: sop-core-0.2.5.0
mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d #
Lift the given function.
Since: sop-core-0.2.5.0
mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c #
Lift the given function.
Since: sop-core-0.2.5.0
mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e #
Lift the given function.
Since: sop-core-0.2.5.0
mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c #
Lift the given function.
Since: sop-core-0.2.5.0
mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e #
Lift the given function.
Since: sop-core-0.2.5.0
mapKKI :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> K b e -> I c #
Lift the given function.
Since: sop-core-0.2.5.0
mapKKK :: forall {k1} {k2} {k3} a b c (d :: k1) (e :: k2) (f :: k3). (a -> b -> c) -> K a d -> K b e -> K c f #
Lift the given function.
Since: sop-core-0.2.5.0
newtype ((f :: k -> Type) -.-> (g :: k -> Type)) (a :: k) infixr 1 #
Lifted functions.
Instances
type Code ((f -.-> g) a) | |
Defined in Generics.SOP.Instances | |
type DatatypeInfoOf ((f -.-> g) a) | |
Defined in Generics.SOP.Instances type DatatypeInfoOf ((f -.-> g) a) = 'Newtype "Data.SOP.Classes" "-.->" ('Record "Fn" '['FieldInfo "apFn"]) |
Proxy
is a type that holds no data, but has a phantom parameter of
arbitrary type (or even kind). Its use is to provide type information, even
though there is no value available of that type (or it may be too costly to
create one).
Historically,
is a safer alternative to the
Proxy
:: Proxy
a
idiom.undefined
:: a
>>>
Proxy :: Proxy (Void, Int -> Int)
Proxy
Proxy can even hold types of higher kinds,
>>>
Proxy :: Proxy Either
Proxy
>>>
Proxy :: Proxy Functor
Proxy
>>>
Proxy :: Proxy complicatedStructure
Proxy
Constructors
Proxy |
Instances
Generic1 (Proxy :: k -> Type) | |
FromJSON1 (Proxy :: Type -> Type) | |
ToJSON1 (Proxy :: TYPE LiftedRep -> Type) | |
Defined in Data.Aeson.Types.ToJSON Methods liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Proxy a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Proxy a] -> Encoding # | |
Foldable (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Eq1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Ord1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Show1 (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
NFData1 (Proxy :: TYPE LiftedRep -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Hashable1 (Proxy :: Type -> Type) | |
Defined in Data.Hashable.Class | |
FromJSON (Proxy a) | |
ToJSON (Proxy a) | |
Defined in Data.Aeson.Types.ToJSON | |
Data t => Data (Proxy t) | Since: base-4.7.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Proxy t -> c (Proxy t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Proxy t) # toConstr :: Proxy t -> Constr # dataTypeOf :: Proxy t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Proxy t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Proxy t)) # gmapT :: (forall b. Data b => b -> b) -> Proxy t -> Proxy t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r # gmapQ :: (forall d. Data d => d -> u) -> Proxy t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Proxy t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) # | |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Generic (Proxy t) | |
Ix (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy | |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Hashable (Proxy a) | |
Defined in Data.Hashable.Class | |
type Rep1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
type Rep (Proxy t) | Since: base-4.6.0.0 |
type Code (Proxy t) | |
Defined in Generics.SOP.Instances | |
type DatatypeInfoOf (Proxy t) | |
Defined in Generics.SOP.Instances type DatatypeInfoOf (Proxy t) = 'ADT "Data.Proxy" "Proxy" '['Constructor "Proxy"] '['[] :: [StrictnessInfo]] |