| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Barbie.Internal
Synopsis
- gbmapDefault :: CanDeriveFunctorB b f g => (forall a. f a -> g a) -> b f -> b g
- class GFunctorB f g repbf repbg where
- gbmap :: (forall a. f a -> g a) -> repbf x -> repbg x
- type CanDeriveFunctorB b f g = (GenericN (b f), GenericN (b g), GFunctorB f g (RepN (b f)) (RepN (b g)))
- gbtraverseDefault :: forall b f g t. (Applicative t, CanDeriveTraversableB b f g) => (forall a. f a -> t (g a)) -> b f -> t (b g)
- class GTraversableB f g repbf repbg where
- gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> repbf x -> t (repbg x)
- type CanDeriveTraversableB b f g = (GenericN (b f), GenericN (b g), GTraversableB f g (RepN (b f)) (RepN (b g)))
- gbuniqDefault :: forall b f. CanDeriveProductB b f f => (forall a. f a) -> b f
- gbprodDefault :: forall b f g. CanDeriveProductB b f g => b f -> b g -> b (f `Product` g)
- class GProductB (f :: k -> *) (g :: k -> *) repbf repbg repbfg where
- type CanDeriveProductB b f g = (GenericN (b f), GenericN (b g), GenericN (b (f `Product` g)), GProductB f g (RepN (b f)) (RepN (b g)) (RepN (b (f `Product` g))))
- gbaddDictsDefault :: forall b c f. (CanDeriveConstraintsB c b f, AllB c b) => b f -> b (Dict c `Product` f)
- class GAllBC repbx => GConstraintsB c (f :: k -> *) repbx repbf repbdf where
- gbaddDicts :: GAllB c repbx => repbf x -> repbdf x
- type CanDeriveConstraintsB c b f = (GenericN (b f), GenericN (b (Dict c `Product` f)), AllB c b ~ GAllB c (GAllBRep b), GConstraintsB c f (GAllBRep b) (RepN (b f)) (RepN (b (Dict c `Product` f))))
- class GAllBC (repbf :: * -> *) where
- type GAllB (c :: k -> Constraint) repbf :: Constraint
- type GAllBRep b = TagSelf b (RepN (b X))
- data X a
- type family TagSelf (b :: (k -> *) -> *) (repbf :: * -> *) :: * -> * where ...
- data Self (b :: (k -> *) -> *) (f :: k -> *)
- data Other (b :: (k -> *) -> *) (f :: k -> *)
- gbdictsDefault :: forall b c. (CanDeriveProductBC c b, AllB c b) => b (Dict c)
- class GProductBC c repbx repbd where
- type CanDeriveProductBC c b = (GenericN (b (Dict c)), AllB c b ~ GAllB c (GAllBRep b), GProductBC c (GAllBRep b) (RepN (b (Dict c))))
- gbcoverDefault :: CanDeriveBareB b => b Bare Identity -> b Covered Identity
- gbstripDefault :: CanDeriveBareB b => b Covered Identity -> b Bare Identity
- class GBareB repbi repbb where
- type CanDeriveBareB b = (GenericN (b Bare Identity), GenericN (b Covered Identity), GBareB (RepN (b Covered Identity)) (RepN (b Bare Identity)))
- class (Coercible (Rep a) (RepN a), Generic a) => GenericN (a :: Type)
- newtype Rec (p :: Type) a x = Rec {}
- type family RepN (a :: Type) :: Type -> Type
Functor
gbmapDefault :: CanDeriveFunctorB b f g => (forall a. f a -> g a) -> b f -> b g Source #
class GFunctorB f g repbf repbg where Source #
Instances
| GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
| GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
| GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
| (GFunctorB f g l l', GFunctorB f g r r') => GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (l :+: r :: k1 -> Type) (l' :+: r' :: k1 -> Type) Source # | |
| (GFunctorB f g l l', GFunctorB f g r r') => GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (l :*: r :: k1 -> Type) (l' :*: r' :: k1 -> Type) Source # | |
| GFunctorB f g bf bg => GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (M1 i c bf :: k1 -> Type) (M1 i c bg :: k1 -> Type) Source # | |
type CanDeriveFunctorB b f g = (GenericN (b f), GenericN (b g), GFunctorB f g (RepN (b f)) (RepN (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:
Traversable
gbtraverseDefault :: forall b f g t. (Applicative t, CanDeriveTraversableB b f g) => (forall a. f a -> t (g a)) -> b f -> t (b g) Source #
class GTraversableB f g repbf repbg where Source #
Methods
gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> repbf x -> t (repbg x) Source #
Instances
| GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> U1 x -> t (U1 x) Source # | |
| GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> V1 x -> t (V1 x) Source # | |
| GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a0 :: k). f a0 -> t (g a0)) -> Rec a a x -> t (Rec a a x) Source # | |
| (GTraversableB f g l l', GTraversableB f g r r') => GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (l :+: r :: k1 -> Type) (l' :+: r' :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> (l :+: r) x -> t ((l' :+: r') x) Source # | |
| (GTraversableB f g l l', GTraversableB f g r r') => GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (l :*: r :: k1 -> Type) (l' :*: r' :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> (l :*: r) x -> t ((l' :*: r') x) Source # | |
| GTraversableB f g bf bg => GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (M1 i c bf :: k1 -> Type) (M1 i c bg :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> M1 i c bf x -> t (M1 i c bg x) Source # | |
type CanDeriveTraversableB b f g = (GenericN (b f), GenericN (b g), GTraversableB f g (RepN (b f)) (RepN (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 fcan contain fields of typeb fas long as there exists ainstance. In particular, recursive usages ofTraversableBbB fare allowed.B fcan also contain usages ofb funder a. For example, one could useTraversablehwhen definingMaybe(B f)B f.
Product
gbuniqDefault :: forall b f. CanDeriveProductB b f f => (forall a. f a) -> b f Source #
gbprodDefault :: forall b f g. CanDeriveProductB b f g => b f -> b g -> b (f `Product` g) Source #
class GProductB (f :: k -> *) (g :: k -> *) repbf repbg repbfg where Source #
Instances
| GProductB (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
| (GProductB f g lf lg lfg, GProductB f g rf rg rfg) => GProductB (f :: k2 -> Type) (g :: k2 -> Type) (lf :*: rf :: k1 -> Type) (lg :*: rg :: k1 -> Type) (lfg :*: rfg :: k1 -> Type) Source # | |
| GProductB f g repf repg repfg => GProductB (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 # | |
type CanDeriveProductB b f g = (GenericN (b f), GenericN (b g), GenericN (b (f `Product` g)), GProductB f g (RepN (b f)) (RepN (b g)) (RepN (b (f `Product` g)))) Source #
is in practice a predicate about CanDeriveProductB B f gB only.
Intuitively, it says that the following holds, for any arbitrary f:
- There is an instance of
.Generic(B f) Bhas only one constructor (that is, it is not a sum-type).- Every field of
B fis of the formf a, for some typea. In other words,Bhas no "hidden" structure.
Constraints
gbaddDictsDefault :: forall b c f. (CanDeriveConstraintsB c b f, AllB c b) => b f -> b (Dict c `Product` f) Source #
class GAllBC repbx => GConstraintsB c (f :: k -> *) repbx repbf repbdf where Source #
Methods
gbaddDicts :: GAllB c repbx => repbf x -> repbdf x Source #
Instances
| GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (U1 :: Type -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (V1 :: Type -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (Rec a a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| (GConstraintsB c f lx lf ldf, GConstraintsB c f rx rf rdf) => GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (lx :+: rx) (lf :+: rf :: k1 -> Type) (ldf :+: rdf :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| (GConstraintsB c f lx lf ldf, GConstraintsB c f rx rf rdf) => GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (lx :*: rx) (lf :*: rf :: k1 -> Type) (ldf :*: rdf :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| GConstraintsB c f repbx repbf repbdf => GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (M1 i k4 repbx) (M1 i k4 repbf :: k1 -> Type) (M1 i k4 repbdf :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
type CanDeriveConstraintsB c b f = (GenericN (b f), GenericN (b (Dict c `Product` f)), AllB c b ~ GAllB c (GAllBRep b), GConstraintsB c f (GAllBRep b) (RepN (b f)) (RepN (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 fcan contain fields of typeb fas long as there exists ainstance. In particular, recursive usages ofConstraintsBbB fare allowed.
class GAllBC (repbf :: * -> *) Source #
Associated Types
type GAllB (c :: k -> Constraint) repbf :: Constraint Source #
Instances
| GAllBC (V1 :: Type -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c V1 :: Constraint Source # | |
| GAllBC (U1 :: Type -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c U1 :: Constraint Source # | |
| (GAllBC l, GAllBC r) => GAllBC (l :+: r) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c (l :+: r) :: Constraint Source # | |
| (GAllBC l, GAllBC r) => GAllBC (l :*: r) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c (l :*: r) :: Constraint Source # | |
| GAllBC (Rec a a :: Type -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c (Rec a a) :: Constraint Source # | |
| GAllBC repbf => GAllBC (M1 i k repbf) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c (M1 i k repbf) :: Constraint Source # | |
type family TagSelf (b :: (k -> *) -> *) (repbf :: * -> *) :: * -> * where ... Source #
We use type-families to generically compute . Intuitively, if
AllB c bb' f occurs inside b f, then we should just add AllB b' c to
AllB b c. The problem is that if b 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 `AllB b f` to break the recursion. Our trick will be to use a type
family to inspect RepN (b f) and distinguish recursive usages from
non-recursive ones, tagging them with different types, so we can distinguish
them in the instances.
Equations
| TagSelf b (M1 mt m s) = M1 mt m (TagSelf b s) | |
| TagSelf b (l :+: r) = TagSelf b l :+: TagSelf b r | |
| TagSelf b (l :*: r) = TagSelf b l :*: TagSelf b r | |
| TagSelf b (Rec (b f) (b g)) = Rec (Self b f) (b g) | |
| TagSelf (b :: (k -> *) -> *) (Rec (b' f) ((b'' :: (k -> *) -> *) g)) = Rec (Other b' f) (b'' g) | |
| TagSelf b (Rec p a) = Rec p a | |
| TagSelf b U1 = U1 | |
| TagSelf b V1 = V1 |
Proof
gbdictsDefault :: forall b c. (CanDeriveProductBC c b, AllB c b) => b (Dict c) Source #
class GProductBC c repbx repbd where Source #
Instances
| GProductBC (c :: k2 -> Constraint) (U1 :: Type -> Type) (U1 :: k1 -> Type) Source # | |
| (GProductBC c lx ld, GProductBC c rx rd) => GProductBC (c :: k2 -> Constraint) (lx :*: rx) (ld :*: rd :: k1 -> Type) Source # | |
| GProductBC c repbx repbd => GProductBC (c :: k2 -> Constraint) (M1 i k3 repbx) (M1 i k3 repbd :: k1 -> Type) Source # | |
type CanDeriveProductBC c b = (GenericN (b (Dict c)), AllB c b ~ GAllB c (GAllBRep b), GProductBC c (GAllBRep b) (RepN (b (Dict c)))) Source #
Every type that admits a generic instance of ProductB and
ConstraintsB, has a generic instance of ProductBC as well.
Bare values
gbcoverDefault :: CanDeriveBareB b => b Bare Identity -> b Covered Identity Source #
gbstripDefault :: CanDeriveBareB b => b Covered Identity -> b Bare Identity Source #
class GBareB repbi repbb where Source #
Instances
| GBareB (V1 :: Type -> Type) (V1 :: Type -> Type) Source # | |
| GBareB (U1 :: Type -> Type) (U1 :: Type -> Type) Source # | |
| (GBareB l l', GBareB r r') => GBareB (l :+: r) (l' :+: r') Source # | |
| (GBareB l l', GBareB r r') => GBareB (l :*: r) (l' :*: r') Source # | |
| repbi ~ repbb => GBareB (Rec repbi repbi :: Type -> Type) (Rec repbb repbb :: Type -> Type) Source # | |
| GBareB repbi repbb => GBareB (M1 i k repbi) (M1 i k repbb) Source # | |
type CanDeriveBareB b = (GenericN (b Bare Identity), GenericN (b Covered Identity), GBareB (RepN (b Covered Identity)) (RepN (b Bare Identity))) Source #
Generic derivation support
class (Coercible (Rep a) (RepN a), Generic a) => GenericN (a :: Type) Source #
Minimal complete definition
toN, fromN
newtype Rec (p :: Type) a x Source #
Instances
| GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (Rec a a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |
| GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # | |
| GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # | |
Defined in Data.Barbie.Internal.Traversable Methods gbtraverse :: Applicative t => (forall (a0 :: k). f a0 -> t (g a0)) -> Rec a a x -> t (Rec a a x) Source # | |
| GAllBC (Rec a a :: Type -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints Associated Types type GAllB c (Rec a a) :: Constraint Source # | |
| repbi ~ repbb => GBareB (Rec repbi repbi :: Type -> Type) (Rec repbb repbb :: Type -> Type) Source # | |
| type GAllB (c :: k -> Constraint) (Rec a a :: Type -> Type) Source # | |
Defined in Data.Barbie.Internal.Constraints | |