barbies-1.1.2.1: Classes for working with types that can change clothes.

Safe HaskellNone
LanguageHaskell2010

Data.Barbie.Internal

Contents

Synopsis

Functor

gbmapDefault :: CanDeriveFunctorB b f g => (forall a. f a -> g a) -> b f -> b g Source #

Default implementation of bmap based on Generic.

class GFunctorB f g repbf repbg where Source #

Methods

gbmap :: (forall a. f a -> g a) -> repbf x -> repbg x Source #

Instances
GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> U1 x -> U1 x Source #

GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> V1 x -> V1 x Source #

GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> Rec x x x0 -> Rec x x x0 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 # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> (l :+: r) x -> (l' :+: r') x 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 # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> (l :*: r) x -> (l' :*: r') x 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 # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> M1 i c bf x -> M1 i c bg x Source #

type CanDeriveFunctorB b f g = (GenericN (b f), GenericN (b g), GFunctorB f g (RepN (b f)) (RepN (b g))) Source #

CanDeriveFunctorB B f g is in practice a predicate about B 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 type b f as long as there exists a FunctorB b instance. In particular, recursive usages of B f are allowed.
  • B f can also contain usages of b f under a Functor h. For example, one could use Maybe (B f) when defining B 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 #

Default implementation of btraverse based on Generic.

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 #

CanDeriveTraversableB B f g is in practice a predicate about B 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 type b f as long as there exists a TraversableB b instance. In particular, recursive usages of B f are allowed.
  • B f can also contain usages of b f under a Traversable h. For example, one could use Maybe (B f) when defining 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 #

Default implementation of bprod based on Generic.

class GProductB (f :: k -> *) (g :: k -> *) repbf repbg repbfg where Source #

Methods

gbprod :: repbf x -> repbg x -> repbfg x Source #

gbuniq :: (forall a. f a) -> repbf x Source #

Instances
GProductB (f :: k2 -> Type) (g :: k2 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) (U1 :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Product

Methods

gbprod :: U1 x -> U1 x -> U1 x Source #

gbuniq :: (forall (a :: k). f a) -> U1 x 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 # 
Instance details

Defined in Data.Barbie.Internal.Product

Methods

gbprod :: (lf :*: rf) x -> (lg :*: rg) x -> (lfg :*: rfg) x Source #

gbuniq :: (forall (a :: k). f a) -> (lf :*: rf) x 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 # 
Instance details

Defined in Data.Barbie.Internal.Product

Methods

gbprod :: M1 i c repf x -> M1 i c repg x -> M1 i c repfg x Source #

gbuniq :: (forall (a :: k). f a) -> M1 i c repf x 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 #

CanDeriveProductB B f g is in practice a predicate about B 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 of the form f a, for some type a. In other words, B has no "hidden" structure.

Constraints

gbaddDictsDefault :: forall b c f. (CanDeriveConstraintsB c b f, AllB c b) => b f -> b (Dict c `Product` f) Source #

Default implementation of baddDicts based on Generic.

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 # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c U1 => U1 x -> U1 x Source #

GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (V1 :: Type -> Type) (V1 :: k1 -> Type) (V1 :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c V1 => V1 x -> V1 x Source #

GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (Rec a a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (Rec a a) => Rec a a x -> Rec a a x Source #

(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 # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (lx :+: rx) => (lf :+: rf) x -> (ldf :+: rdf) x Source #

(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 # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (lx :*: rx) => (lf :*: rf) x -> (ldf :*: rdf) x Source #

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 # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (M1 i k4 repbx) => M1 i k4 repbf x -> M1 i k4 repbdf x Source #

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 #

CanDeriveConstraintsB B f g is in practice a predicate about B 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 type b f as long as there exists a ConstraintsB b instance. In particular, recursive usages of B f are allowed.

class GAllBC (repbf :: * -> *) Source #

Associated Types

type GAllB (c :: k -> Constraint) repbf :: Constraint Source #

Instances
GAllBC (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c V1 :: Constraint Source #

GAllBC (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c U1 :: Constraint Source #

(GAllBC l, GAllBC r) => GAllBC (l :+: r) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c (l :+: r) :: Constraint Source #

(GAllBC l, GAllBC r) => GAllBC (l :*: r) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c (l :*: r) :: Constraint Source #

GAllBC (Rec a a :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c (Rec a a) :: Constraint Source #

GAllBC repbf => GAllBC (M1 i k repbf) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c (M1 i k repbf) :: Constraint Source #

type GAllBRep b = TagSelf b (RepN (b X)) Source #

The representation used for the generic computation of the AllB c b constraints. Here X is an arbitrary constant since the actual argument to b is irrelevant.

data X a Source #

type family TagSelf (b :: (k -> *) -> *) (repbf :: * -> *) :: * -> * where ... Source #

We use type-families to generically compute AllB c b. Intuitively, if b' 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 

data Self (b :: (k -> *) -> *) (f :: k -> *) Source #

data Other (b :: (k -> *) -> *) (f :: k -> *) Source #

Proof

gbdictsDefault :: forall b c. (CanDeriveProductBC c b, AllB c b) => b (Dict c) Source #

Default implementation of bproof based on Generic.

class GProductBC c repbx repbd where Source #

Methods

gbdicts :: GAllB c repbx => repbd x Source #

Instances
GProductBC (c :: k2 -> Constraint) (U1 :: Type -> Type) (U1 :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.ProductC

Methods

gbdicts :: GAllB c U1 => U1 x Source #

(GProductBC c lx ld, GProductBC c rx rd) => GProductBC (c :: k2 -> Constraint) (lx :*: rx) (ld :*: rd :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.ProductC

Methods

gbdicts :: GAllB c (lx :*: rx) => (ld :*: rd) x Source #

GProductBC c repbx repbd => GProductBC (c :: k2 -> Constraint) (M1 i k3 repbx) (M1 i k3 repbd :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.ProductC

Methods

gbdicts :: GAllB c (M1 i k3 repbx) => M1 i k3 repbd x 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 #

Default implementation of bstrip based on Generic.

gbstripDefault :: CanDeriveBareB b => b Covered Identity -> b Bare Identity Source #

Default implementation of bstrip based on Generic.

class GBareB repbi repbb where Source #

Methods

gbstrip :: repbi x -> repbb x Source #

gbcover :: repbb x -> repbi x Source #

Instances
GBareB (V1 :: Type -> Type) (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: V1 x -> V1 x Source #

gbcover :: V1 x -> V1 x Source #

GBareB (U1 :: Type -> Type) (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: U1 x -> U1 x Source #

gbcover :: U1 x -> U1 x Source #

(GBareB l l', GBareB r r') => GBareB (l :+: r) (l' :+: r') Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: (l :+: r) x -> (l' :+: r') x Source #

gbcover :: (l' :+: r') x -> (l :+: r) x Source #

(GBareB l l', GBareB r r') => GBareB (l :*: r) (l' :*: r') Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: (l :*: r) x -> (l' :*: r') x Source #

gbcover :: (l' :*: r') x -> (l :*: r) x Source #

repbi ~ repbb => GBareB (Rec repbi repbi :: Type -> Type) (Rec repbb repbb :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: Rec repbi repbi x -> Rec repbb repbb x Source #

gbcover :: Rec repbb repbb x -> Rec repbi repbi x Source #

GBareB repbi repbb => GBareB (M1 i k repbi) (M1 i k repbb) Source # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: M1 i k repbi x -> M1 i k repbb x Source #

gbcover :: M1 i k repbb x -> M1 i k repbi x Source #

type CanDeriveBareB b = (GenericN (b Bare Identity), GenericN (b Covered Identity), GBareB (RepN (b Covered Identity)) (RepN (b Bare Identity))) Source #

All types that admit a generic FunctorB' instance, and have all their occurrences of f under a Wear admit a generic BareB instance.

Generic derivation support

class (Coercible (Rep a) (RepN a), Generic a) => GenericN (a :: Type) Source #

Minimal complete definition

toN, fromN

Instances
(Coercible (Rep a) (RepN a), Generic a) => GenericN a Source # 
Instance details

Defined in Data.Generics.GenericN

Associated Types

type RepN a :: Type -> Type Source #

Methods

toN :: RepN a x -> a

fromN :: a -> RepN a x

newtype Rec (p :: Type) a x Source #

Constructors

Rec 

Fields

Instances
GConstraintsB (c :: k3 -> Constraint) (f :: k2 -> Type) (Rec a a :: Type -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (Rec a a) => Rec a a x -> Rec a a x Source #

GFunctorB (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k1 -> Type) (Rec x x :: k1 -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall (a :: k). f a -> g a) -> Rec x x x0 -> Rec x x x0 Source #

GTraversableB (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k1 -> Type) (Rec a a :: k1 -> Type) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: Rec repbi repbi x -> Rec repbb repbb x Source #

gbcover :: Rec repbb repbb x -> Rec repbi repbi x Source #

type GAllB (c :: k -> Constraint) (Rec a a :: Type -> Type) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

type GAllB (c :: k -> Constraint) (Rec a a :: Type -> Type) = ()

type family RepN (a :: Type) :: Type -> Type Source #

Instances
type RepN a Source # 
Instance details

Defined in Data.Generics.GenericN

type RepN a