barbies-1.0.0.0: 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 #

Minimal complete definition

gbmap

Methods

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

Instances
GFunctorB f g (U1 :: * -> *) (U1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

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

GFunctorB f g (V1 :: * -> *) (V1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

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

GFunctorB f g (Rec x x :: * -> *) (Rec x x :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

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

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall a. f a -> g a) -> (l :+: r) x -> (l' :+: r') x Source #

(GFunctorB f g l l', GFunctorB f g r r') => GFunctorB f g (l :*: r) (l' :*: r') Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall a. f a -> g a) -> (l :*: r) x -> (l' :*: r') x Source #

GFunctorB f g bf bg => GFunctorB f g (M1 i c bf) (M1 i c bg) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

gbmap :: (forall a. 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 #

Minimal complete definition

gbtraverse

Methods

gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> repbf x -> t (repbg x) Source #

Instances
GTraversableB f g (U1 :: * -> *) (U1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> U1 x -> t (U1 x) Source #

GTraversableB f g (V1 :: * -> *) (V1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> V1 x -> t (V1 x) Source #

GTraversableB f g (Rec a a :: * -> *) (Rec a a :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a0. 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 g (l :+: r) (l' :+: r') Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a. 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 g (l :*: r) (l' :*: r') Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a. f a -> t (g a)) -> (l :*: r) x -> t ((l' :*: r') x) Source #

GTraversableB f g bf bg => GTraversableB f g (M1 i c bf) (M1 i c bg) Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a. 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 :: * -> *) (g :: * -> *) repbf repbg repbfg where Source #

Minimal complete definition

gbprod, gbuniq

Methods

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

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

Instances
GProductB f g (U1 :: * -> *) (U1 :: * -> *) (U1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Product

Methods

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

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

(GProductB f g lf lg lfg, GProductB f g rf rg rfg) => GProductB f g (lf :*: rf) (lg :*: rg) (lfg :*: rfg) Source # 
Instance details

Defined in Data.Barbie.Internal.Product

Methods

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

gbuniq :: (forall a. f a) -> (lf :*: rf) x Source #

GProductB f g repf repg repfg => GProductB f g (M1 i c repf) (M1 i c repg) (M1 i c repfg) 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. 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 :: * -> *) repbx repbf repbdf where Source #

Minimal complete definition

gbaddDicts

Methods

gbaddDicts :: GAllB c repbx => repbf x -> repbdf x Source #

Instances
GConstraintsB c f (U1 :: * -> *) (U1 :: * -> *) (U1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

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

GConstraintsB c f (V1 :: * -> *) (V1 :: * -> *) (V1 :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

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

GConstraintsB c f (Rec a a :: * -> *) (Rec a a :: * -> *) (Rec a a :: * -> *) 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 f (lx :+: rx) (lf :+: rf) (ldf :+: rdf) 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 f (lx :*: rx) (lf :*: rf) (ldf :*: rdf) 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 f (M1 i k repbx) (M1 i k repbf) (M1 i k repbdf) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

Methods

gbaddDicts :: GAllB c (M1 i k repbx) => M1 i k repbf x -> M1 i k 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 :: * -> Constraint) repbf :: Constraint Source #

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

Defined in Data.Barbie.Internal.Constraints

Associated Types

type GAllB c V1 :: Constraint Source #

GAllBC (U1 :: * -> *) 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 :: * -> *) 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 :: (* -> *) -> *) (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 (Rec (b' f) (b'' (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 :: (* -> *) -> *) (f :: * -> *) Source #

data Other (b :: (* -> *) -> *) (f :: * -> *) 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 #

Minimal complete definition

gbdicts

Methods

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

Instances
GProductBC c (U1 :: * -> *) (U1 :: * -> *) 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 (lx :*: rx) (ld :*: rd) 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 (M1 i k repbx) (M1 i k repbd) Source # 
Instance details

Defined in Data.Barbie.Internal.ProductC

Methods

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

Minimal complete definition

gbstrip, gbcover

Methods

gbstrip :: repbi x -> repbb x Source #

gbcover :: repbb x -> repbi x Source #

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

Defined in Data.Barbie.Internal.Bare

Methods

gbstrip :: V1 x -> V1 x Source #

gbcover :: V1 x -> V1 x Source #

GBareB (U1 :: * -> *) (U1 :: * -> *) 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 :: * -> *) (Rec repbb repbb :: * -> *) 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
GFunctorB f g (Rec x x :: * -> *) (Rec x x :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Functor

Methods

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

GTraversableB f g (Rec a a :: * -> *) (Rec a a :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Traversable

Methods

gbtraverse :: Applicative t => (forall a0. f a0 -> t (g a0)) -> Rec a a x -> t (Rec a a x) Source #

GConstraintsB c f (Rec a a :: * -> *) (Rec a a :: * -> *) (Rec a a :: * -> *) 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 #

GAllBC (Rec a a :: * -> *) 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 :: * -> *) (Rec repbb repbb :: * -> *) 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 (Rec a a :: * -> *) Source # 
Instance details

Defined in Data.Barbie.Internal.Constraints

type GAllB c (Rec a a :: * -> *) = ()

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

Instances
type RepN a Source # 
Instance details

Defined in Data.Generics.GenericN

type RepN a