Safe Haskell | None |
---|---|
Language | Haskell2010 |
Introduces closed representations functor for GHC.Generics style generics.
Synopsis
- class Generic a
- type family Rep a :: Type -> Type
- type family Rep1 (f :: k -> Type) :: k -> Type
- data Par1 p
- data Rec1 (f :: k -> Type) (p :: k) :: forall k. (k -> Type) -> k -> Type
- newtype ((f :: k2 -> Type) :.: (g :: k1 -> k2)) (p :: k1) :: forall k2 k1. (k2 -> Type) -> (k1 -> k2) -> k1 -> Type = Comp1 {
- unComp1 :: f (g p)
- data V1 (p :: k) :: forall k. k -> Type
- data U1 (p :: k) :: forall k. k -> Type = U1
- data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type
- data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type = (f p) :*: (g p)
- newtype K1 i c (p :: k) :: forall k. Type -> Type -> k -> Type = K1 {
- unK1 :: c
- newtype M1 i (c :: Meta) (f :: k -> Type) (p :: k) :: forall k. Type -> Meta -> (k -> Type) -> k -> Type = M1 {
- unM1 :: f p
- data (c :=>: (f :: k -> Type)) (a :: k) :: forall k. Constraint -> (k -> Type) -> k -> Type where
- data R
- class GMeta i c where
- data SMeta i t where
- data SMetaI d f x = SMetaI
- data SRep w f where
- newtype I x = I {
- unI :: x
- type Simplistic a = (Generic a, GShallow (Rep a))
- type family OnLeaves (c :: * -> Constraint) (f :: * -> *) :: Constraint where ...
- repMap :: (forall y. f y -> g y) -> SRep f rep -> SRep g rep
- repMapM :: Monad m => (forall y. f y -> m (g y)) -> SRep f rep -> m (SRep g rep)
- repMapCM :: (Monad m, OnLeaves c rep) => Proxy c -> (forall y. c y => f y -> m (g y)) -> SRep f rep -> m (SRep g rep)
- zipSRep :: SRep w f -> SRep z f -> Maybe (SRep (w :*: z) f)
- repLeaves :: (forall x. w x -> r) -> (r -> r -> r) -> r -> SRep w rep -> r
- repLeavesC :: OnLeaves c rep => Proxy c -> (forall x. c x => w x -> r) -> (r -> r -> r) -> r -> SRep w rep -> r
- repLeavesList :: SRep w rep -> [Exists w]
- getDatatypeName :: SMeta D d -> String
- getConstructorName :: SMeta C c -> String
- repDatatypeName :: SRep w f -> String
- repConstructorName :: SRep w f -> String
- fromS :: Simplistic a => a -> SRep I (Rep a)
- toS :: Simplistic a => SRep I (Rep a) -> a
- class GShallow f where
- data SRep1 f x where
- S1_U1 :: SRep1 U1 x
- S1_L1 :: SRep1 f x -> SRep1 (f :+: g) x
- S1_R1 :: SRep1 g x -> SRep1 (f :+: g) x
- (:***:) :: SRep1 f x -> SRep1 g x -> SRep1 (f :*: g) x
- S1_K1 :: a -> SRep1 (K1 i a) x
- S1_M1 :: SMeta i t -> SRep1 f x -> SRep1 (M1 i t f) x
- S1_ST :: c => SRep1 f x -> SRep1 (c :=>: f) x
- S1_Par :: x -> SRep1 Par1 x
- S1_Rec :: f x -> SRep1 (Rec1 f) x
- S1_Comp :: f (SRep1 g x) -> SRep1 (f :.: g) x
- type family OnLeaves1 (c :: * -> Constraint) (r :: (* -> *) -> Constraint) (f :: * -> *) :: Constraint where ...
- fromS1 :: Simplistic1 f => f x -> SRep1 (Rep1 f) x
- toS1 :: Simplistic1 f => SRep1 (Rep1 f) x -> f x
- class GShallow1 f where
- type Simplistic1 f = (Generic1 f, GShallow1 (Rep1 f))
- class c => d => Implies c d
- class Trivial c
Re-exports from GHC.Generics.Extra module
Representable types of kind *
.
This class is derivable in GHC with the DeriveGeneric
flag on.
A Generic
instance must satisfy the following laws:
from
.to
≡id
to
.from
≡id
Instances
type family Rep a :: Type -> Type #
Generic representation type
Instances
type family Rep1 (f :: k -> Type) :: k -> Type #
Generic representation type
Instances
Used for marking occurrences of the parameter
Instances
Monad Par1 | Since: base-4.9.0.0 |
Functor Par1 | Since: base-4.9.0.0 |
MonadFix Par1 | Since: base-4.9.0.0 |
Defined in Control.Monad.Fix | |
Applicative Par1 | Since: base-4.9.0.0 |
Foldable Par1 | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => Par1 m -> m # foldMap :: Monoid m => (a -> m) -> Par1 a -> m # foldr :: (a -> b -> b) -> b -> Par1 a -> b # foldr' :: (a -> b -> b) -> b -> Par1 a -> b # foldl :: (b -> a -> b) -> b -> Par1 a -> b # foldl' :: (b -> a -> b) -> b -> Par1 a -> b # foldr1 :: (a -> a -> a) -> Par1 a -> a # foldl1 :: (a -> a -> a) -> Par1 a -> a # elem :: Eq a => a -> Par1 a -> Bool # maximum :: Ord a => Par1 a -> a # | |
Traversable Par1 | Since: base-4.9.0.0 |
GShallow1 Par1 Source # | |
GNFData One Par1 | |
Defined in Control.DeepSeq | |
Eq p => Eq (Par1 p) | Since: base-4.7.0.0 |
Ord p => Ord (Par1 p) | Since: base-4.7.0.0 |
Read p => Read (Par1 p) | Since: base-4.7.0.0 |
Show p => Show (Par1 p) | Since: base-4.7.0.0 |
Generic (Par1 p) | |
Semigroup p => Semigroup (Par1 p) | Since: base-4.12.0.0 |
Monoid p => Monoid (Par1 p) | Since: base-4.12.0.0 |
Generic1 Par1 | |
type Rep (Par1 p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
type Rep1 Par1 | Since: base-4.9.0.0 |
Defined in GHC.Generics |
data Rec1 (f :: k -> Type) (p :: k) :: forall k. (k -> Type) -> k -> Type #
Recursive calls of kind * -> *
(or kind k -> *
, when PolyKinds
is enabled)
Instances
Generic1 (Rec1 f :: k -> Type) | |
NFData1 f => GNFData One (Rec1 f) | |
Defined in Control.DeepSeq | |
Monad f => Monad (Rec1 f) | Since: base-4.9.0.0 |
Functor f => Functor (Rec1 f) | Since: base-4.9.0.0 |
MonadFix f => MonadFix (Rec1 f) | Since: base-4.9.0.0 |
Defined in Control.Monad.Fix | |
Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
Foldable f => Foldable (Rec1 f) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => Rec1 f m -> m # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b # foldr1 :: (a -> a -> a) -> Rec1 f a -> a # foldl1 :: (a -> a -> a) -> Rec1 f a -> a # elem :: Eq a => a -> Rec1 f a -> Bool # maximum :: Ord a => Rec1 f a -> a # minimum :: Ord a => Rec1 f a -> a # | |
Traversable f => Traversable (Rec1 f) | Since: base-4.9.0.0 |
Alternative f => Alternative (Rec1 f) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (Rec1 f) | Since: base-4.9.0.0 |
GShallow1 (Rec1 f) Source # | |
Eq (f p) => Eq (Rec1 f p) | Since: base-4.7.0.0 |
Ord (f p) => Ord (Rec1 f p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
Read (f p) => Read (Rec1 f p) | Since: base-4.7.0.0 |
Show (f p) => Show (Rec1 f p) | Since: base-4.7.0.0 |
Generic (Rec1 f p) | |
Semigroup (f p) => Semigroup (Rec1 f p) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (Rec1 f p) | Since: base-4.12.0.0 |
type Rep1 (Rec1 f :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (Rec1 f p) | Since: base-4.7.0.0 |
Defined in GHC.Generics |
newtype ((f :: k2 -> Type) :.: (g :: k1 -> k2)) (p :: k1) :: forall k2 k1. (k2 -> Type) -> (k1 -> k2) -> k1 -> Type infixr 7 #
Composition of functors
Instances
Functor f => Generic1 (f :.: g :: k -> Type) | |
(NFData1 f, GNFData One g) => GNFData One (f :.: g) | |
Defined in Control.DeepSeq | |
(Functor f, Functor g) => Functor (f :.: g) | Since: base-4.9.0.0 |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :.: g) m -> 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 # | |
(Traversable f, Traversable g) => Traversable (f :.: g) | Since: base-4.9.0.0 |
(Alternative f, Applicative g) => Alternative (f :.: g) | Since: base-4.9.0.0 |
(Functor f, GShallow1 g) => GShallow1 (f :.: g) Source # | |
Eq (f (g p)) => Eq ((f :.: g) p) | Since: base-4.7.0.0 |
Ord (f (g p)) => Ord ((f :.: g) p) | Since: base-4.7.0.0 |
Read (f (g p)) => Read ((f :.: g) p) | Since: base-4.7.0.0 |
Show (f (g p)) => Show ((f :.: g) p) | Since: base-4.7.0.0 |
Generic ((f :.: g) p) | |
Semigroup (f (g p)) => Semigroup ((f :.: g) p) | Since: base-4.12.0.0 |
Monoid (f (g p)) => Monoid ((f :.: g) p) | Since: base-4.12.0.0 |
type Rep1 (f :.: g :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep ((f :.: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics |
data V1 (p :: k) :: forall k. k -> Type #
Void: used for datatypes without constructors
Instances
Generic1 (V1 :: k -> Type) | |
GNFData arity (V1 :: Type -> Type) | |
Defined in Control.DeepSeq | |
EqHO (V1 :: ki -> Type) Source # | |
Functor (V1 :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (V1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => V1 m -> m # foldMap :: Monoid m => (a -> m) -> V1 a -> m # foldr :: (a -> b -> b) -> b -> V1 a -> b # foldr' :: (a -> b -> b) -> b -> V1 a -> b # foldl :: (b -> a -> b) -> b -> V1 a -> b # foldl' :: (b -> a -> b) -> b -> V1 a -> b # foldr1 :: (a -> a -> a) -> V1 a -> a # foldl1 :: (a -> a -> a) -> V1 a -> a # elem :: Eq a => a -> V1 a -> Bool # maximum :: Ord a => V1 a -> a # | |
Traversable (V1 :: Type -> Type) | Since: base-4.9.0.0 |
GShallow1 (V1 :: Type -> Type) Source # | |
Eq (V1 p) | Since: base-4.9.0.0 |
Ord (V1 p) | Since: base-4.9.0.0 |
Read (V1 p) | Since: base-4.9.0.0 |
Show (V1 p) | Since: base-4.9.0.0 |
Generic (V1 p) | |
Semigroup (V1 p) | Since: base-4.12.0.0 |
NFData (V1 x) Source # | |
Defined in Generics.Simplistic.Deep | |
type Rep1 (V1 :: k -> Type) | Since: base-4.9.0.0 |
type Rep (V1 p) | Since: base-4.9.0.0 |
data U1 (p :: k) :: forall k. k -> Type #
Unit: used for constructors without arguments
Instances
GDeep kappa fam (U1 :: k -> Type) Source # | |
Generic1 (U1 :: k -> Type) | |
GNFData arity (U1 :: Type -> Type) | |
Defined in Control.DeepSeq | |
EqHO (U1 :: ki -> Type) Source # | |
GShallow (U1 :: k -> Type) Source # | |
Monad (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Functor (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # | |
Traversable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Alternative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (U1 :: Type -> Type) | Since: base-4.9.0.0 |
GShallow1 (U1 :: Type -> Type) Source # | |
(All Eq kappa, EqHO h) => EqHO (Holes kappa fam h :: Type -> Type) Source # | |
Eq (U1 p) | Since: base-4.9.0.0 |
Ord (U1 p) | Since: base-4.7.0.0 |
Read (U1 p) | Since: base-4.9.0.0 |
Show (U1 p) | Since: base-4.9.0.0 |
Generic (U1 p) | |
Semigroup (U1 p) | Since: base-4.12.0.0 |
Monoid (U1 p) | Since: base-4.12.0.0 |
NFData (U1 x) Source # | |
Defined in Generics.Simplistic.Deep | |
(All Eq kappa, EqHO h) => Eq (Holes kappa fam h t) Source # | |
type Rep1 (U1 :: k -> Type) | Since: base-4.9.0.0 |
type Rep (U1 p) | Since: base-4.7.0.0 |
data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type infixr 5 #
Sums: encode choice between constructors
Instances
(GDeep kappa fam f, GDeep kappa fam g) => GDeep kappa fam (f :+: g :: k -> Type) Source # | |
Generic1 (f :+: g :: k -> Type) | |
(GNFData arity a, GNFData arity b) => GNFData arity (a :+: b) | |
Defined in Control.DeepSeq | |
(GShallow f, GShallow g) => GShallow (f :+: g :: k -> Type) Source # | |
(Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :+: g) m -> 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 # | |
(Traversable f, Traversable g) => Traversable (f :+: g) | Since: base-4.9.0.0 |
(GShallow1 f, GShallow1 g) => GShallow1 (f :+: g) Source # | |
(Eq (f p), Eq (g p)) => Eq ((f :+: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :+: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :+: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :+: g) p) | Since: base-4.7.0.0 |
Generic ((f :+: g) p) | |
type Rep1 (f :+: g :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics type Rep1 (f :+: g :: k -> Type) = D1 (MetaData ":+:" "GHC.Generics" "base" False) (C1 (MetaCons "L1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f)) :+: C1 (MetaCons "R1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep ((f :+: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics type Rep ((f :+: g) p) = D1 (MetaData ":+:" "GHC.Generics" "base" False) (C1 (MetaCons "L1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p))) :+: C1 (MetaCons "R1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p)))) |
data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type infixr 6 #
Products: encode multiple arguments to constructors
(f p) :*: (g p) infixr 6 |
Instances
(GDeep kappa fam f, GDeep kappa fam g) => GDeep kappa fam (f :*: g :: k -> Type) Source # | |
Generic1 (f :*: g :: k -> Type) | |
(GNFData arity a, GNFData arity b) => GNFData arity (a :*: b) | |
Defined in Control.DeepSeq | |
(ShowHO f, ShowHO g) => ShowHO (f :*: g :: ki -> Type) Source # | |
(EqHO f, EqHO g) => EqHO (f :*: g :: ki -> Type) Source # | |
(GShallow f, GShallow g) => GShallow (f :*: g :: k -> Type) Source # | |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0 |
(MonadFix f, MonadFix g) => MonadFix (f :*: g) | Since: base-4.9.0.0 |
Defined in Control.Monad.Fix | |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :*: g) m -> 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 # | |
(Traversable f, Traversable g) => Traversable (f :*: g) | Since: base-4.9.0.0 |
(Alternative f, Alternative g) => Alternative (f :*: g) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (f :*: g) | Since: base-4.9.0.0 |
(GShallow1 f, GShallow1 g) => GShallow1 (f :*: g) Source # | |
(Eq (f p), Eq (g p)) => Eq ((f :*: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :*: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :*: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :*: g) p) | Since: base-4.7.0.0 |
Generic ((f :*: g) p) | |
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) | Since: base-4.12.0.0 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0 |
type Rep1 (f :*: g :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics type Rep1 (f :*: g :: k -> Type) = D1 (MetaData ":*:" "GHC.Generics" "base" False) (C1 (MetaCons ":*:" (InfixI RightAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep ((f :*: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics type Rep ((f :*: g) p) = D1 (MetaData ":*:" "GHC.Generics" "base" False) (C1 (MetaCons ":*:" (InfixI RightAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p)))) |
newtype K1 i c (p :: k) :: forall k. Type -> Type -> k -> Type #
Constants, additional parameters and recursion of kind *
Instances
GDeepAtom kappa fam (IsElem a kappa) a => GDeep kappa fam (K1 R a :: k -> Type) Source # | |
Generic1 (K1 i c :: k -> Type) | |
NFData a => GNFData arity (K1 i a :: Type -> Type) | |
Defined in Control.DeepSeq | |
GShallow (K1 R x :: k -> Type) Source # | |
Functor (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
Foldable (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => K1 i c m -> m # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m # foldr :: (a -> b -> b) -> b -> K1 i c a -> b # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b # foldl :: (b -> a -> b) -> b -> K1 i c a -> b # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b # foldr1 :: (a -> a -> a) -> K1 i c a -> a # foldl1 :: (a -> a -> a) -> K1 i c a -> a # elem :: Eq a => a -> K1 i c a -> Bool # maximum :: Ord a => K1 i c a -> a # minimum :: Ord a => K1 i c a -> a # | |
Traversable (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
GShallow1 (K1 i a :: Type -> Type) Source # | |
Eq c => Eq (K1 i c p) | Since: base-4.7.0.0 |
Ord c => Ord (K1 i c p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
Read c => Read (K1 i c p) | Since: base-4.7.0.0 |
Show c => Show (K1 i c p) | Since: base-4.7.0.0 |
Generic (K1 i c p) | |
Semigroup c => Semigroup (K1 i c p) | Since: base-4.12.0.0 |
Monoid c => Monoid (K1 i c p) | Since: base-4.12.0.0 |
type Rep1 (K1 i c :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (K1 i c p) | Since: base-4.7.0.0 |
Defined in GHC.Generics |
newtype M1 i (c :: Meta) (f :: k -> Type) (p :: k) :: forall k. Type -> Meta -> (k -> Type) -> k -> Type #
Meta-information (constructor names, etc.)
Instances
(GMeta i c, GDeep kappa fam f) => GDeep kappa fam (M1 i c f :: k -> Type) Source # | |
Generic1 (M1 i c f :: k -> Type) | |
GNFData arity a => GNFData arity (M1 i c a) | |
Defined in Control.DeepSeq | |
(GShallow f, GMeta i c) => GShallow (M1 i c f :: k -> Type) Source # | |
Monad f => Monad (M1 i c f) | Since: base-4.9.0.0 |
Functor f => Functor (M1 i c f) | Since: base-4.9.0.0 |
MonadFix f => MonadFix (M1 i c f) | Since: base-4.9.0.0 |
Defined in Control.Monad.Fix | |
Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # | |
Traversable f => Traversable (M1 i c f) | Since: base-4.9.0.0 |
Alternative f => Alternative (M1 i c f) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (M1 i c f) | Since: base-4.9.0.0 |
(GMeta i t, GShallow1 f) => GShallow1 (M1 i t f) Source # | |
Eq (f p) => Eq (M1 i c f p) | Since: base-4.7.0.0 |
Ord (f p) => Ord (M1 i c f p) | Since: base-4.7.0.0 |
Read (f p) => Read (M1 i c f p) | Since: base-4.7.0.0 |
Show (f p) => Show (M1 i c f p) | Since: base-4.7.0.0 |
Generic (M1 i c f p) | |
Semigroup (f p) => Semigroup (M1 i c f p) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (M1 i c f p) | Since: base-4.12.0.0 |
type Rep1 (M1 i c f :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (M1 i c f p) | Since: base-4.7.0.0 |
Defined in GHC.Generics |
data (c :=>: (f :: k -> Type)) (a :: k) :: forall k. Constraint -> (k -> Type) -> k -> Type where #
Constraints: used to represent constraints in a constructor.
data Showable a = Show a => a -> X a instance Generic (Showable a) where type Rep (Showable a) = (Show a) :=>: (K1 R a)
Tag for K1: recursion (of kind Type
)
Simplistic representation on *
types
class GMeta i c where Source #
Singletons for metainformation
Given some a
, a value of type SRep w (Rep a)
is
a closed representation of a generic value of type a
.
S_U1 :: SRep w U1 | |
S_L1 :: SRep w f -> SRep w (f :+: g) | |
S_R1 :: SRep w g -> SRep w (f :+: g) | |
(:**:) :: SRep w f -> SRep w g -> SRep w (f :*: g) infixr 5 | |
S_K1 :: w a -> SRep w (K1 i a) | |
S_M1 :: SMeta i t -> SRep w f -> SRep w (M1 i t f) | |
S_ST :: c => SRep w f -> SRep w (c :=>: f) |
Identity functor
type Simplistic a = (Generic a, GShallow (Rep a)) Source #
All types supported by GHC.Generics are simplistic, this constraint just couples their necessary together.
Constraints over the leaves of a data type
type family OnLeaves (c :: * -> Constraint) (f :: * -> *) :: Constraint where ... Source #
Computes the constraint that corresponds to ensuring all leaves of a representation satisfy a given constraint. For example,
OnLeaves Eq (Rep (Either a b)) = (Eq a , Eq b)
Combinators
Maps , zips and folds
repMap :: (forall y. f y -> g y) -> SRep f rep -> SRep g rep Source #
Maps a simple functino over the representation
repMapM :: Monad m => (forall y. f y -> m (g y)) -> SRep f rep -> m (SRep g rep) Source #
Maps a monadic function over the representation
:: (Monad m, OnLeaves c rep) | |
=> Proxy c | Which constraint shall be threaded through |
-> (forall y. c y => f y -> m (g y)) | |
-> SRep f rep | |
-> m (SRep g rep) |
Maps a function over a representation taking into account that the leaves of the representation satisfy a given constraint.
zipSRep :: SRep w f -> SRep z f -> Maybe (SRep (w :*: z) f) Source #
Zips two representations together if they are made up of the same constructor. For example,
zipSRep (fromS (: 1 [])) (fromS (: 2 (: 3 []))) == Just (fromS (: (1 , 2) ([] , [3]))) zipSRep (fromS (: 1 [])) (fromS []) == Nothing
:: (forall x. w x -> r) | leaf extraction |
-> (r -> r -> r) | join product |
-> r | empty |
-> SRep w rep | |
-> r |
Performs a crush over the leaves of a SRep
:: OnLeaves c rep | |
=> Proxy c | |
-> (forall x. c x => w x -> r) | leaf extraction |
-> (r -> r -> r) | join product |
-> r | empty |
-> SRep w rep | |
-> r |
Performs a crush over the leaves of a SRep
carrying a constraint
around.
repLeavesList :: SRep w rep -> [Exists w] Source #
Example of repLeaves
that places the values of w
inside
a list.
Metadata
repDatatypeName :: SRep w f -> String Source #
Retrieves the datatype name for a representation.
WARNING; UNSAFE this function only works if f
is the representation of
a type constructed with GHC.Generics builtin mechanisms.
repConstructorName :: SRep w f -> String Source #
Retrieves the constructor name for a representation.
WARNING; UNSAFE this function only works if f
is the representation of
a type constructed with GHC.Generics builtin mechanisms.
Shallow Conversion
fromS :: Simplistic a => a -> SRep I (Rep a) Source #
Converts a value of a generic type directly to its (shallow) simplistic representation.
toS :: Simplistic a => SRep I (Rep a) -> a Source #
Converts a simplistic representation back to its corresponding
value of type a
.
class GShallow f where Source #
Shallow conversion between GHC.Generics representation
and SRep
; The fromS
and toS
functions provide the
toplevel api.
Simplistic representation on * -> *
types
Similar to SRep
, but is indexed over the functors that
make up a Rep1
, used to explicitely encode types with
one parameter.
S1_U1 :: SRep1 U1 x | |
S1_L1 :: SRep1 f x -> SRep1 (f :+: g) x | |
S1_R1 :: SRep1 g x -> SRep1 (f :+: g) x | |
(:***:) :: SRep1 f x -> SRep1 g x -> SRep1 (f :*: g) x infixr 5 | |
S1_K1 :: a -> SRep1 (K1 i a) x | |
S1_M1 :: SMeta i t -> SRep1 f x -> SRep1 (M1 i t f) x | |
S1_ST :: c => SRep1 f x -> SRep1 (c :=>: f) x | |
S1_Par :: x -> SRep1 Par1 x | |
S1_Rec :: f x -> SRep1 (Rec1 f) x | |
S1_Comp :: f (SRep1 g x) -> SRep1 (f :.: g) x |
type family OnLeaves1 (c :: * -> Constraint) (r :: (* -> *) -> Constraint) (f :: * -> *) :: Constraint where ... Source #
OnLeaves1 c r V1 = () | |
OnLeaves1 c r U1 = () | |
OnLeaves1 c r (f :+: g) = (OnLeaves1 c r f, OnLeaves1 c r g) | |
OnLeaves1 c r (f :*: g) = (OnLeaves1 c r f, OnLeaves1 c r g) | |
OnLeaves1 c r (K1 i a) = c a | |
OnLeaves1 c r (M1 i p f) = OnLeaves1 c r f | |
OnLeaves1 c r (d :=>: f) = Implies d (OnLeaves1 c r f) | |
OnLeaves1 c r Par1 = () | |
OnLeaves1 c r (Rec1 f) = r f | |
OnLeaves1 c r (f :.: g) = (r f, OnLeaves1 c r g) |
fromS1 :: Simplistic1 f => f x -> SRep1 (Rep1 f) x Source #
Converts a value of a generic type directly to its (shallow) simplistic1 representation with a parameter.
toS1 :: Simplistic1 f => SRep1 (Rep1 f) x -> f x Source #
Converts a simplistic1 representation back to its corresponding
value of type a
.
class GShallow1 f where Source #
Instances
GShallow1 Par1 Source # | |
GShallow1 (V1 :: Type -> Type) Source # | |
GShallow1 (U1 :: Type -> Type) Source # | |
GShallow1 (Rec1 f) Source # | |
GShallow1 (K1 i a :: Type -> Type) Source # | |
(GShallow1 f, GShallow1 g) => GShallow1 (f :+: g) Source # | |
(GShallow1 f, GShallow1 g) => GShallow1 (f :*: g) Source # | |
c -> GShallow1 f => GShallow1 (c :=>: f) Source # | |
(GMeta i t, GShallow1 f) => GShallow1 (M1 i t f) Source # | |
(Functor f, GShallow1 g) => GShallow1 (f :.: g) Source # | |