Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- gbmapDefault :: CanDeriveFunctorB b f g => (forall a. f a -> g a) -> b f -> b g
- class GFunctor (n :: Nat) f g repbf repbg where
- type CanDeriveFunctorB b f g = (GenericP 0 (b f), GenericP 0 (b g), GFunctor 0 f g (RepP 0 (b f)) (RepP 0 (b g)))
- type CanDeriveFunctorT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GFunctor 1 f g (RepP 1 (t f x)) (RepP 1 (t g x)))
- gbtraverseDefault :: forall b f g e. (Applicative e, CanDeriveTraversableB b f g) => (forall a. f a -> e (g a)) -> b f -> e (b g)
- class GTraversable n f g repbf repbg where
- gtraverse :: Applicative t => Proxy n -> (forall a. f a -> t (g a)) -> repbf x -> t (repbg x)
- type CanDeriveTraversableB b f g = (GenericP 0 (b f), GenericP 0 (b g), GTraversable 0 f g (RepP 0 (b f)) (RepP 0 (b g)))
- type CanDeriveTraversableT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GTraversable 1 f g (RepP 1 (t f x)) (RepP 1 (t g x)))
- gbdistributeDefault :: CanDeriveDistributiveB b f g => Functor f => f (b g) -> b (Compose f g)
- class Functor f => GDistributive (n :: Nat) f repbg repbfg where
- gdistribute :: Proxy n -> f (repbg x) -> repbfg x
- type CanDeriveDistributiveB b f g = (GenericP 0 (b g), GenericP 0 (b (Compose f g)), GDistributive 0 f (RepP 0 (b g)) (RepP 0 (b (Compose f g))))
- type CanDeriveDistributiveT (t :: (Type -> Type) -> i -> Type) f g x = (GenericP 1 (t g x), GenericP 1 (t (Compose f g) x), GDistributive 1 f (RepP 1 (t g x)) (RepP 1 (t (Compose f g) x)))
- gbpureDefault :: forall b f. CanDeriveApplicativeB b f f => (forall a. f a) -> b f
- gbprodDefault :: forall b f g. CanDeriveApplicativeB b f g => b f -> b g -> b (f `Product` g)
- class GApplicative n (f :: k -> *) (g :: k -> *) repbf repbg repbfg where
- type CanDeriveApplicativeB b f g = (GenericP 0 (b f), GenericP 0 (b g), GenericP 0 (b (f `Product` g)), GApplicative 0 f g (RepP 0 (b f)) (RepP 0 (b g)) (RepP 0 (b (f `Product` g))))
- type CanDeriveApplicativeT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GenericP 1 (t (f `Product` g) x), GApplicative 1 f g (RepP 1 (t f x)) (RepP 1 (t g x)) (RepP 1 (t (f `Product` g) x)))
- gbaddDictsDefault :: forall b c f. (CanDeriveConstraintsB c b f, AllB c b) => b f -> b (Dict c `Product` f)
- class GConstraints n c f repbx repbf repbdf where
- type CanDeriveConstraintsB c b f = (GenericP 0 (b f), GenericP 0 (b (Dict c `Product` f)), AllB c b ~ GAll 0 c (GAllRepB b), GConstraints 0 c f (GAllRepB b) (RepP 0 (b f)) (RepP 0 (b (Dict c `Product` f))))
- type CanDeriveConstraintsT c t f x = (GenericP 1 (t f x), GenericP 1 (t (Dict c `Product` f) x), AllT c t ~ GAll 1 c (GAllRepT t), GConstraints 1 c f (GAllRepT t) (RepP 1 (t f x)) (RepP 1 (t (Dict c `Product` f) x)))
- type family GAll (n :: Nat) (c :: k -> Constraint) (repbf :: Type -> Type) :: Constraint
- type GAllRepB b = TagSelf 0 b (RepN (b X))
- type GAllRepT t = TagSelf 1 t (RepN (t X Y))
- data X a
- data family Y :: k
- type TagSelf n b repbf = TagSelf' n b (Indexed b (n + 1)) repbf
- type family TagSelf' (n :: Nat) (b :: kb) (b' :: kb) (repbf :: * -> *) :: * -> * where ...
- data family Self (b :: k -> k') :: k -> k'
- data family Other (b :: k -> k') :: k -> k'
- gbcoverDefault :: CanDeriveBareB b => b Bare Identity -> b Covered Identity
- gbstripDefault :: CanDeriveBareB b => b Covered Identity -> b Bare Identity
- class GBare (n :: Nat) repbi repbb where
- type CanDeriveBareB b = (GenericP 0 (b Bare Identity), GenericP 0 (b Covered Identity), GBare 0 (RepP 0 (b Covered Identity)) (RepP 0 (b Bare Identity)))
- data family Param (n :: Nat) (a :: k) :: k
- type family Indexed (t :: k) (i :: Nat) :: k where ...
- type family FilterIndex (n :: Nat) (t :: k) :: k where ...
- type family Zip (a :: Type -> Type) (b :: Type -> Type) :: Type -> Type where ...
- newtype Rec (p :: Type) a x = Rec {}
- class (Coercible (Rep a) (RepN a), Generic a) => GenericN (a :: Type) where
- class (Coercible (Rep a) (RepP n a), Generic a) => GenericP (n :: Nat) (a :: Type) where
- module GHC.Generics
Functor
gbmapDefault :: CanDeriveFunctorB b f g => (forall a. f a -> g a) -> b f -> b g Source #
class GFunctor (n :: Nat) f g repbf repbg where Source #
Instances
GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
(GFunctor n f g l l', GFunctor n f g r r') => GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (l :+: r :: k1 -> Type) (l' :+: r' :: k1 -> Type) Source # | |
(GFunctor n f g l l', GFunctor n f g r r') => GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (l :*: r :: k1 -> Type) (l' :*: r' :: k1 -> Type) Source # | |
GFunctor n f g bf bg => GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (M1 i c bf :: k1 -> Type) (M1 i c bg :: k1 -> Type) Source # | |
type CanDeriveFunctorB b f g = (GenericP 0 (b f), GenericP 0 (b g), GFunctor 0 f g (RepP 0 (b f)) (RepP 0 (b g))) Source #
is in practice a predicate about CanDeriveFunctorB
B f gB
only.
Intuitively, it says that the following holds, for any arbitrary f
:
type CanDeriveFunctorT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GFunctor 1 f g (RepP 1 (t f x)) (RepP 1 (t g x))) Source #
is in practice a predicate about CanDeriveFunctorT
T f g xT
only.
Intuitively, it says that the following holds, for any arbitrary f
:
Traversable
gbtraverseDefault :: forall b f g e. (Applicative e, CanDeriveTraversableB b f g) => (forall a. f a -> e (g a)) -> b f -> e (b g) Source #
class GTraversable n f g repbf repbg where Source #
gtraverse :: Applicative t => Proxy n -> (forall a. f a -> t (g a)) -> repbf x -> t (repbg x) Source #
Instances
GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
(GTraversable n f g l l', GTraversable n f g r r') => GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (l :+: r :: k1 -> Type) (l' :+: r' :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
(GTraversable n f g l l', GTraversable n f g r r') => GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (l :*: r :: k1 -> Type) (l' :*: r' :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
GTraversable n f g bf bg => GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (M1 i c bf :: k1 -> Type) (M1 i c bg :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable |
type CanDeriveTraversableB b f g = (GenericP 0 (b f), GenericP 0 (b g), GTraversable 0 f g (RepP 0 (b f)) (RepP 0 (b g))) Source #
is in practice a predicate about CanDeriveTraversableB
B f gB
only.
It is analogous to CanDeriveFunctorB
, so it
essentially requires the following to hold, for any arbitrary f
:
- There is an instance of
.Generic
(B f) B f
can contain fields of typeb f
as long as there exists a
instance. In particular, recursive usages ofTraversableB
bB f
are allowed.B f
can also contain usages ofb f
under a
. For example, one could useTraversable
h
when definingMaybe
(B f)B f
.
type CanDeriveTraversableT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GTraversable 1 f g (RepP 1 (t f x)) (RepP 1 (t g x))) Source #
is in practice a predicate about CanDeriveTraversableT
T f g xT
only.
It is analogous to CanDeriveFunctorT
, so it
essentially requires the following to hold, for any arbitrary f
:
- There is an instance of
.Generic
(T f x) T f x
can contain fields of typet f x
as long as there exists a
instance. In particular, recursive usages ofTraversableT
tT f x
are allowed.T f x
can also contain usages oft f x
under a
. For example, one could useTraversable
h
when definingMaybe
(T f x)T f x
.
Distributive
gbdistributeDefault :: CanDeriveDistributiveB b f g => Functor f => f (b g) -> b (Compose f g) Source #
Default implementation of bdistribute
based on Generic
.
class Functor f => GDistributive (n :: Nat) f repbg repbfg where Source #
gdistribute :: Proxy n -> f (repbg x) -> repbfg x Source #
Instances
Functor f => GDistributive n f (U1 :: k -> Type) (U1 :: k -> Type) Source # | |
Defined in Barbies.Generics.Distributive | |
(GDistributive n f l l', GDistributive n f r r') => GDistributive n f (l :*: r :: k -> Type) (l' :*: r' :: k -> Type) Source # | |
Defined in Barbies.Generics.Distributive | |
GDistributive n f bg bfg => GDistributive n f (M1 i c bg :: k -> Type) (M1 i c bfg :: k -> Type) Source # | |
Defined in Barbies.Generics.Distributive |
type CanDeriveDistributiveB b f g = (GenericP 0 (b g), GenericP 0 (b (Compose f g)), GDistributive 0 f (RepP 0 (b g)) (RepP 0 (b (Compose f g)))) Source #
is in practice a predicate about CanDeriveDistributiveB
B f gB
only.
Intuitively, it says the the following holds for any arbitrary f
:
- There is an instance of
.Generic
(B f) (B f)
has only one constructor, and doesn't contain "naked" fields (that is, not covered byf
).B f
can contain fields of typeb f
as long as there exists a
instance. In particular, recursive usages ofDistributiveB
bB f
are allowed.B f
can also contain usages ofb f
under a
. For example, one could useDistributive
ha -> (B f)
as a field ofB f
.
type CanDeriveDistributiveT (t :: (Type -> Type) -> i -> Type) f g x = (GenericP 1 (t g x), GenericP 1 (t (Compose f g) x), GDistributive 1 f (RepP 1 (t g x)) (RepP 1 (t (Compose f g) x))) Source #
is in practice a predicate about CanDeriveDistributiveT
T f g xT
only.
Intuitively, it says the the following holds for any arbitrary f
:
- There is an instance of
.Generic
(B f x) (B f x)
has only one constructor, and doesn't contain "naked" fields (that is, not covered byf
). In particular,x
needs to occur underf
.B f x
can contain fields of typeb f y
as long as there exists a
instance. In particular, recursive usages ofDistributiveT
bB f x
are allowed.B f x
can also contain usages ofb f y
under a
. For example, one could useDistributive
ha -> (B f x)
as a field ofB f x
.
Applicative
gbpureDefault :: forall b f. CanDeriveApplicativeB b f f => (forall a. f a) -> b f Source #
gbprodDefault :: forall b f g. CanDeriveApplicativeB b f g => b f -> b g -> b (f `Product` g) Source #
class GApplicative n (f :: k -> *) (g :: k -> *) repbf repbg repbfg where Source #
gprod :: Proxy n -> Proxy f -> Proxy g -> repbf x -> repbg x -> repbfg x Source #
gpure :: (f ~ g, repbf ~ repbg) => Proxy n -> Proxy f -> Proxy repbf -> Proxy repbfg -> (forall a. f a) -> repbf x Source #
Instances
GApplicative (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
Monoid x => GApplicative (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
(GApplicative n f g lf lg lfg, GApplicative n f g rf rg rfg) => GApplicative (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (lf :*: rf :: k1 -> Type) (lg :*: rg :: k1 -> Type) (lfg :*: rfg :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Applicative | |
GApplicative n f g repf repg repfg => GApplicative (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (M1 i c repf :: k1 -> Type) (M1 i c repg :: k1 -> Type) (M1 i c repfg :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Applicative |
type CanDeriveApplicativeB b f g = (GenericP 0 (b f), GenericP 0 (b g), GenericP 0 (b (f `Product` g)), GApplicative 0 f g (RepP 0 (b f)) (RepP 0 (b g)) (RepP 0 (b (f `Product` g)))) Source #
is in practice a predicate about CanDeriveApplicativeB
B f gB
only.
Intuitively, it says that the following holds, for any arbitrary f
:
- There is an instance of
.Generic
(B f) B
has only one constructor (that is, it is not a sum-type).- Every field of
B f
is either a monoid, or of the formf a
, for some typea
.
type CanDeriveApplicativeT t f g x = (GenericP 1 (t f x), GenericP 1 (t g x), GenericP 1 (t (f `Product` g) x), GApplicative 1 f g (RepP 1 (t f x)) (RepP 1 (t g x)) (RepP 1 (t (f `Product` g) x))) Source #
is in practice a predicate about CanDeriveApplicativeT
T f g xT
only.
Intuitively, it says that the following holds, for any arbitrary f
:
- There is an instance of
.Generic
(T f) T
has only one constructor (that is, it is not a sum-type).- Every field of
T f x
is either a monoid, or of the formf a
, for some typea
.
Constraints
gbaddDictsDefault :: forall b c f. (CanDeriveConstraintsB c b f, AllB c b) => b f -> b (Dict c `Product` f) Source #
class GConstraints n c f repbx repbf repbdf where Source #
Instances
GConstraints n (c :: k3 -> Constraint) (f :: k2) (U1 :: Type -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
GConstraints n (c :: k3 -> Constraint) (f :: k2) (V1 :: Type -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
GConstraints n (c :: k3 -> Constraint) (f :: k2) (Rec a' a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
(GConstraints n c f lx lf ldf, GConstraints n c f rx rf rdf) => GConstraints n (c :: k3 -> Constraint) (f :: k2) (lx :+: rx) (lf :+: rf :: k1 -> Type) (ldf :+: rdf :: k1 -> Type) Source # | |
(GConstraints n c f lx lf ldf, GConstraints n c f rx rf rdf) => GConstraints n (c :: k3 -> Constraint) (f :: k2) (lx :*: rx) (lf :*: rf :: k1 -> Type) (ldf :*: rdf :: k1 -> Type) Source # | |
GConstraints n c f repbx repbf repbdf => GConstraints n (c :: k3 -> Constraint) (f :: k2) (M1 i k4 repbx) (M1 i k4 repbf :: k1 -> Type) (M1 i k4 repbdf :: k1 -> Type) Source # | |
type CanDeriveConstraintsB c b f = (GenericP 0 (b f), GenericP 0 (b (Dict c `Product` f)), AllB c b ~ GAll 0 c (GAllRepB b), GConstraints 0 c f (GAllRepB b) (RepP 0 (b f)) (RepP 0 (b (Dict c `Product` f)))) Source #
is in practice a predicate about CanDeriveConstraintsB
B f gB
only.
Intuitively, it says that the following holds, for any arbitrary f
:
- There is an instance of
.Generic
(B f) B f
can contain fields of typeb f
as long as there exists a
instance. In particular, recursive usages ofConstraintsB
bB f
are allowed.
type CanDeriveConstraintsT c t f x = (GenericP 1 (t f x), GenericP 1 (t (Dict c `Product` f) x), AllT c t ~ GAll 1 c (GAllRepT t), GConstraints 1 c f (GAllRepT t) (RepP 1 (t f x)) (RepP 1 (t (Dict c `Product` f) x))) Source #
is in practice a predicate about CanDeriveConstraintsT
T f g xT
only.
Intuitively, it says that the following holds, for any arbitrary f
and x
:
- There is an instance of
.Generic
(T f x) T f
can contain fields of typet f x
as long as there exists a
instance. In particular, recursive usages ofConstraintsT
tT f x
are allowed.
type family GAll (n :: Nat) (c :: k -> Constraint) (repbf :: Type -> Type) :: Constraint Source #
Instances
type GAll n (c :: k -> Constraint) (U1 :: Type -> Type) Source # | |
Defined in Barbies.Generics.Constraints | |
type GAll n (c :: k -> Constraint) (V1 :: Type -> Type) Source # | |
Defined in Barbies.Generics.Constraints | |
type GAll n (c :: k -> Constraint) (Rec a a :: Type -> Type) Source # | |
Defined in Barbies.Generics.Constraints | |
type GAll n (c :: k -> Constraint) (l :+: r) Source # | |
Defined in Barbies.Generics.Constraints | |
type GAll n (c :: k -> Constraint) (l :*: r) Source # | |
Defined in Barbies.Generics.Constraints | |
type GAll n (c :: k1 -> Constraint) (M1 i k2 repbf) Source # | |
Defined in Barbies.Generics.Constraints |
type TagSelf n b repbf = TagSelf' n b (Indexed b (n + 1)) repbf Source #
We use the type-families to generically compute
. Intuitively, if
AllB
c bb' f
occurs inside b f
, then we should just add
to
AllB
b' c
. The problem is that if AllB
b cb
is a recursive type, and b'
is b
,
then ghc will choke and blow the stack (instead of computing a fixpoint).
So, we would like to behave differently when b = b'
and add ()
instead
of
to break the recursion. Our trick will be to use a type
family to inspect AllB
b f
and distinguish recursive usages from
non-recursive ones, tagging them with different types, so we can distinguish
them in the instances.RepN
(b f)
type family TagSelf' (n :: Nat) (b :: kb) (b' :: kb) (repbf :: * -> *) :: * -> * where ... Source #
TagSelf' n b b' (M1 mt m s) = M1 mt m (TagSelf' n b b' s) | |
TagSelf' n b b' (l :+: r) = TagSelf' n b b' l :+: TagSelf' n b b' r | |
TagSelf' n b b' (l :*: r) = TagSelf' n b b' l :*: TagSelf' n b b' r | |
TagSelf' 0 b b' (Rec (b' f) (b g)) = Rec (Self b' f) (b g) | |
TagSelf' 0 (b :: k -> *) b' (Rec ((b'' :: k -> *) f) ((b''' :: k -> *) g)) = Rec (Other b'' f) (b''' g) | |
TagSelf' 1 b b' (Rec (b' fl fr) (b gl gr)) = Rec (Self b' fl fr) (b gl gr) | |
TagSelf' 1 (b :: kl -> kr -> *) b' (Rec ((b'' :: kl -> kr -> *) fl fr) ((b''' :: kl -> kr -> *) gl gr)) = Rec (Other b'' fl fr) (b''' gl gr) | |
TagSelf' n b b' (Rec p a) = Rec p a | |
TagSelf' n b b' U1 = U1 | |
TagSelf' n b b' V1 = V1 |
Bare values
gbcoverDefault :: CanDeriveBareB b => b Bare Identity -> b Covered Identity Source #
gbstripDefault :: CanDeriveBareB b => b Covered Identity -> b Bare Identity Source #
class GBare (n :: Nat) repbi repbb where Source #
Instances
GBare n (U1 :: k -> Type) (U1 :: k -> Type) Source # | |
GBare n (V1 :: k -> Type) (V1 :: k -> Type) Source # | |
repbi ~ repbb => GBare n (Rec repbi repbi :: k -> Type) (Rec repbb repbb :: k -> Type) Source # | |
(GBare n l l', GBare n r r') => GBare n (l :+: r :: k -> Type) (l' :+: r' :: k -> Type) Source # | |
(GBare n l l', GBare n r r') => GBare n (l :*: r :: k -> Type) (l' :*: r' :: k -> Type) Source # | |
GBare n repbi repbb => GBare n (M1 i k2 repbi :: k1 -> Type) (M1 i k2 repbb :: k1 -> Type) Source # | |
type CanDeriveBareB b = (GenericP 0 (b Bare Identity), GenericP 0 (b Covered Identity), GBare 0 (RepP 0 (b Covered Identity)) (RepP 0 (b Bare Identity))) Source #
Generic derivation support
type family FilterIndex (n :: Nat) (t :: k) :: k where ... Source #
FilterIndex n (t (Param n a)) = FilterIndex n t (Param n a) | |
FilterIndex n (t (Param _ a)) = FilterIndex n t a | |
FilterIndex _ t = t |
newtype Rec (p :: Type) a x Source #
Instances
GTraversable (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Barbies.Generics.Traversable | |
GConstraints n (c :: k3 -> Constraint) (f :: k2) (Rec a' a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Monoid x => GApplicative (n :: k3) (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
GFunctor n (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
repbi ~ repbb => GBare n (Rec repbi repbi :: k -> Type) (Rec repbb repbb :: k -> Type) Source # | |
type GAll n (c :: k -> Constraint) (Rec a a :: Type -> Type) Source # | |
Defined in Barbies.Generics.Constraints |
module GHC.Generics