one-liner-0.9.2: Constraint-based generics

LicenseBSD-style (see the file LICENSE)
Maintainersjoerd@w3future.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Generics.OneLiner.Internal

Description

 

Synopsis

Documentation

type family Constraints' (t :: * -> *) (c :: * -> Constraint) (c1 :: (* -> *) -> Constraint) :: Constraint Source #

Instances

type Constraints' Par1 c c1 Source # 
type Constraints' Par1 c c1 = ()
type Constraints' (V1 *) c c1 Source # 
type Constraints' (V1 *) c c1 = ()
type Constraints' (U1 *) c c1 Source # 
type Constraints' (U1 *) c c1 = ()
type Constraints' (Rec1 * f) c c1 Source # 
type Constraints' (Rec1 * f) c c1 = c1 f
type Constraints' (K1 * i a) c c1 Source # 
type Constraints' (K1 * i a) c c1 = c a
type Constraints' ((:+:) * f g) c c1 Source # 
type Constraints' ((:+:) * f g) c c1 = (Constraints' f c c1, Constraints' g c c1)
type Constraints' ((:*:) * f g) c c1 Source # 
type Constraints' ((:*:) * f g) c c1 = (Constraints' f c c1, Constraints' g c c1)
type Constraints' (M1 * i t f) c c1 Source # 
type Constraints' (M1 * i t f) c c1 = Constraints' f c c1
type Constraints' ((:.:) * * f g) c c1 Source # 
type Constraints' ((:.:) * * f g) c c1 = (c1 f, Constraints' g c c1)

type family Satisfies (p :: * -> * -> *) (ks :: [(* -> * -> *) -> Constraint]) :: Constraint Source #

Instances

type Satisfies p ([] ((* -> * -> *) -> Constraint)) Source # 
type Satisfies p ([] ((* -> * -> *) -> Constraint)) = ()
type Satisfies p ((:) ((* -> * -> *) -> Constraint) k ks) Source # 
type Satisfies p ((:) ((* -> * -> *) -> Constraint) k ks) = (k p, Satisfies p ks)

class (ks :: [(* -> * -> *) -> Constraint]) |- (k :: (* -> * -> *) -> Constraint) where Source #

Minimal complete definition

(|-)

Methods

(|-) :: Satisfies p ks => proxy0 ks -> proxy1 k -> (k p => p a b) -> p a b Source #

Instances

((:) ((* -> * -> *) -> Constraint) k _ks) |- k Source # 

Methods

(|-) :: Satisfies p ((((* -> * -> *) -> Constraint) ': k) _ks) => proxy0 ((((* -> * -> *) -> Constraint) ': k) _ks) -> proxy1 k -> (k p -> p a b) -> p a b Source #

(|-) ks k => ((:) ((* -> * -> *) -> Constraint) _k ks) |- k Source # 

Methods

(|-) :: Satisfies p ((((* -> * -> *) -> Constraint) ': _k) ks) => proxy0 ((((* -> * -> *) -> Constraint) ': _k) ks) -> proxy1 k -> (k p -> p a b) -> p a b Source #

generic' :: forall t c p ks a b proxy0 for. (ADT_ Identity Proxy ks t, Constraints' t c AnyType, Satisfies p ks) => proxy0 ks -> for c -> (forall s. c s => p s s) -> p (t a) (t b) Source #

generic1' :: forall t c1 p ks a b proxy0 for. (ADT_ Proxy Identity ks t, Constraints' t AnyType c1, Satisfies p ks) => proxy0 ks -> for c1 -> (forall s d e. c1 s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

generic01' :: forall t c0 c1 p ks a b proxy0 for for1. (ADT_ Identity Identity ks t, Constraints' t c0 c1, Satisfies p ks) => proxy0 ks -> for c0 -> (forall s. c0 s => p s s) -> for1 c1 -> (forall s d e. c1 s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

class ADT_ (nullary :: * -> *) (unary :: * -> *) (ks :: [(* -> * -> *) -> Constraint]) (t :: * -> *) where Source #

Minimal complete definition

generic_

Methods

generic_ :: (Constraints' t c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall s1 d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (t a) (t b) Source #

Instances

(|-) ks Profunctor => ADT_ nullary Identity ks Par1 Source # 

Methods

generic_ :: (Constraints' Par1 c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => Identity (p d e -> p (s1 d) (s1 e))) -> Identity (p a b) -> p (Par1 a) (Par1 b) Source #

(|-) ks GenericUnitProfunctor => ADT_ nullary unary ks (U1 *) Source # 

Methods

generic_ :: (Constraints' (U1 *) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (U1 * a) (U1 * b) Source #

(|-) ks GenericEmptyProfunctor => ADT_ nullary unary ks (V1 *) Source # 

Methods

generic_ :: (Constraints' (V1 *) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (V1 * a) (V1 * b) Source #

(|-) ks Profunctor => ADT_ nullary Identity ks (Rec1 * f) Source # 

Methods

generic_ :: (Constraints' (Rec1 * f) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => Identity (p d e -> p (s1 d) (s1 e))) -> Identity (p a b) -> p (Rec1 * f a) (Rec1 * f b) Source #

((|-) ks GenericProductProfunctor, ADT_ nullary unary ks f, ADT_ nullary unary ks g) => ADT_ nullary unary ks ((:*:) * f g) Source # 

Methods

generic_ :: (Constraints' ((* :*: f) g) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p ((* :*: f) g a) ((* :*: f) g b) Source #

((|-) ks GenericSumProfunctor, ADT_ nullary unary ks f, ADT_ nullary unary ks g) => ADT_ nullary unary ks ((:+:) * f g) Source # 

Methods

generic_ :: (Constraints' ((* :+: f) g) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p ((* :+: f) g a) ((* :+: f) g b) Source #

(|-) ks Profunctor => ADT_ Identity unary ks (K1 * i v) Source # 

Methods

generic_ :: (Constraints' (K1 * i v) c c1, Satisfies p ks) => proxy0 ks -> proxy1 Identity -> for c -> (forall s. c s => Identity (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (K1 * i v a) (K1 * i v b) Source #

((|-) ks Profunctor, ADT_ nullary Identity ks g) => ADT_ nullary Identity ks ((:.:) * * f g) Source # 

Methods

generic_ :: (Constraints' ((* :.: *) f g) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => Identity (p d e -> p (s1 d) (s1 e))) -> Identity (p a b) -> p ((* :.: *) f g a) ((* :.: *) f g b) Source #

((|-) ks Profunctor, ADT_ nullary unary ks f) => ADT_ nullary unary ks (M1 * i c f) Source # 

Methods

generic_ :: (Constraints' (M1 * i c f) c c1, Satisfies p ks) => proxy0 ks -> proxy1 nullary -> for c -> (forall s. c s => nullary (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (M1 * i c f a) (M1 * i c f b) Source #

(|-) ks GenericEmptyProfunctor => ADT_ (Proxy *) unary ks (K1 * i v) Source # 

Methods

generic_ :: (Constraints' (K1 * i v) c c1, Satisfies p ks) => proxy0 ks -> proxy1 (Proxy *) -> for c -> (forall s. c s => Proxy * (p s s)) -> for1 c1 -> (forall (s1 :: * -> *) d e. c1 s1 => unary (p d e -> p (s1 d) (s1 e))) -> unary (p a b) -> p (K1 * i v a) (K1 * i v b) Source #

absurd :: V1 a -> b Source #

e1 :: (f a -> b) -> (g a -> b) -> (f :+: g) a -> b Source #

fst1 :: (f :*: g) a -> f a Source #

snd1 :: (f :*: g) a -> g a Source #

class Profunctor p => GenericUnitProfunctor p where Source #

Minimal complete definition

unit

Methods

unit :: p (U1 a) (U1 a') Source #

Instances

Applicative f => GenericUnitProfunctor (Star f) Source # 

Methods

unit :: Star f (U1 k a) (U1 k a') Source #

Functor f => GenericUnitProfunctor (Costar f) Source # 

Methods

unit :: Costar f (U1 k a) (U1 k a') Source #

GenericUnitProfunctor (Tagged *) Source # 

Methods

unit :: Tagged * (U1 k a) (U1 k a') Source #

GenericUnitProfunctor (Ctor *) Source # 

Methods

unit :: Ctor * (U1 k a) (U1 k a') Source #

Applicative f => GenericUnitProfunctor (Zip f) Source # 

Methods

unit :: Zip f (U1 k a) (U1 k a') Source #

GenericUnitProfunctor ((->) LiftedRep LiftedRep) Source # 

Methods

unit :: (LiftedRep -> LiftedRep) (U1 k a) (U1 k a') Source #

Applicative f => GenericUnitProfunctor (Joker * * f) Source # 

Methods

unit :: Joker * * f (U1 k a) (U1 k a') Source #

Divisible f => GenericUnitProfunctor (Clown * * f) Source # 

Methods

unit :: Clown * * f (U1 k a) (U1 k a') Source #

(GenericUnitProfunctor p, GenericUnitProfunctor q) => GenericUnitProfunctor (Product * * p q) Source # 

Methods

unit :: Product * * p q (U1 k a) (U1 k a') Source #

(Applicative f, GenericUnitProfunctor p) => GenericUnitProfunctor (Tannen * * * f p) Source # 

Methods

unit :: Tannen * * * f p (U1 k a) (U1 k a') Source #

(Functor f, Applicative g, Profunctor p, GenericUnitProfunctor p) => GenericUnitProfunctor (Biff * * * * p f g) Source # 

Methods

unit :: Biff * * * * p f g (U1 k a) (U1 k a') Source #

class Profunctor p => GenericProductProfunctor p where Source #

Minimal complete definition

mult

Methods

mult :: p (f a) (f' a') -> p (g a) (g' a') -> p ((f :*: g) a) ((f' :*: g') a') Source #

Instances

Applicative f => GenericProductProfunctor (Star f) Source # 

Methods

mult :: Star f (f a) (f' a') -> Star f (g a) (g' a') -> Star f ((k :*: f) g a) ((k :*: f') g' a') Source #

Functor f => GenericProductProfunctor (Costar f) Source # 

Methods

mult :: Costar f (f a) (f' a') -> Costar f (g a) (g' a') -> Costar f ((k :*: f) g a) ((k :*: f') g' a') Source #

GenericProductProfunctor (Tagged *) Source # 

Methods

mult :: Tagged * (f a) (f' a') -> Tagged * (g a) (g' a') -> Tagged * ((k :*: f) g a) ((k :*: f') g' a') Source #

GenericProductProfunctor (Ctor *) Source # 

Methods

mult :: Ctor * (f a) (f' a') -> Ctor * (g a) (g' a') -> Ctor * ((k :*: f) g a) ((k :*: f') g' a') Source #

Applicative f => GenericProductProfunctor (Zip f) Source # 

Methods

mult :: Zip f (f a) (f' a') -> Zip f (g a) (g' a') -> Zip f ((k :*: f) g a) ((k :*: f') g' a') Source #

GenericProductProfunctor ((->) LiftedRep LiftedRep) Source # 

Methods

mult :: (LiftedRep -> LiftedRep) (f a) (f' a') -> (LiftedRep -> LiftedRep) (g a) (g' a') -> (LiftedRep -> LiftedRep) ((k :*: f) g a) ((k :*: f') g' a') Source #

Applicative f => GenericProductProfunctor (Joker * * f) Source # 

Methods

mult :: Joker * * f (f a) (f' a') -> Joker * * f (g a) (g' a') -> Joker * * f ((k :*: f) g a) ((k :*: f') g' a') Source #

Divisible f => GenericProductProfunctor (Clown * * f) Source # 

Methods

mult :: Clown * * f (f a) (f' a') -> Clown * * f (g a) (g' a') -> Clown * * f ((k :*: f) g a) ((k :*: f') g' a') Source #

(GenericProductProfunctor p, GenericProductProfunctor q) => GenericProductProfunctor (Product * * p q) Source # 

Methods

mult :: Product * * p q (f a) (f' a') -> Product * * p q (g a) (g' a') -> Product * * p q ((k :*: f) g a) ((k :*: f') g' a') Source #

(Applicative f, GenericProductProfunctor p) => GenericProductProfunctor (Tannen * * * f p) Source # 

Methods

mult :: Tannen * * * f p (f a) (f' a') -> Tannen * * * f p (g a) (g' a') -> Tannen * * * f p ((k :*: f) g a) ((k :*: f') g' a') Source #

(Functor f, Applicative g, Profunctor p, GenericProductProfunctor p) => GenericProductProfunctor (Biff * * * * p f g) Source # 

Methods

mult :: Biff * * * * p f g (f a) (f' a') -> Biff * * * * p f g (g a) (g' a') -> Biff * * * * p f g ((k :*: f) g a) ((k :*: f') g' a') Source #

class Profunctor p => GenericSumProfunctor p where Source #

Minimal complete definition

plus

Methods

plus :: p (f a) (f' a') -> p (g a) (g' a') -> p ((f :+: g) a) ((f' :+: g') a') Source #

Instances

Applicative f => GenericSumProfunctor (Star f) Source # 

Methods

plus :: Star f (f a) (f' a') -> Star f (g a) (g' a') -> Star f ((k :+: f) g a) ((k :+: f') g' a') Source #

GenericSumProfunctor (Ctor *) Source # 

Methods

plus :: Ctor * (f a) (f' a') -> Ctor * (g a) (g' a') -> Ctor * ((k :+: f) g a) ((k :+: f') g' a') Source #

Alternative f => GenericSumProfunctor (Zip f) Source # 

Methods

plus :: Zip f (f a) (f' a') -> Zip f (g a) (g' a') -> Zip f ((k :+: f) g a) ((k :+: f') g' a') Source #

GenericSumProfunctor ((->) LiftedRep LiftedRep) Source # 

Methods

plus :: (LiftedRep -> LiftedRep) (f a) (f' a') -> (LiftedRep -> LiftedRep) (g a) (g' a') -> (LiftedRep -> LiftedRep) ((k :+: f) g a) ((k :+: f') g' a') Source #

Alternative f => GenericSumProfunctor (Joker * * f) Source # 

Methods

plus :: Joker * * f (f a) (f' a') -> Joker * * f (g a) (g' a') -> Joker * * f ((k :+: f) g a) ((k :+: f') g' a') Source #

Decidable f => GenericSumProfunctor (Clown * * f) Source # 

Methods

plus :: Clown * * f (f a) (f' a') -> Clown * * f (g a) (g' a') -> Clown * * f ((k :+: f) g a) ((k :+: f') g' a') Source #

(GenericSumProfunctor p, GenericSumProfunctor q) => GenericSumProfunctor (Product * * p q) Source # 

Methods

plus :: Product * * p q (f a) (f' a') -> Product * * p q (g a) (g' a') -> Product * * p q ((k :+: f) g a) ((k :+: f') g' a') Source #

(Applicative f, GenericSumProfunctor p) => GenericSumProfunctor (Tannen * * * f p) Source # 

Methods

plus :: Tannen * * * f p (f a) (f' a') -> Tannen * * * f p (g a) (g' a') -> Tannen * * * f p ((k :+: f) g a) ((k :+: f') g' a') Source #

class Profunctor p => GenericEmptyProfunctor p where Source #

Minimal complete definition

identity, zero

Methods

identity :: p a a Source #

zero :: p (V1 a) (V1 a') Source #

Instances

class (Profunctor p, GenericUnitProfunctor p, GenericProductProfunctor p) => GenericRecordProfunctor p Source #

A generic function using a GenericRecordProfunctor works on any data type with exactly one constructor, a.k.a. records, with multiple fields (mult) or no fields (unit).

GenericRecordProfunctor is similar to ProductProfuctor from the product-profunctor package, but using types from GHC.Generics.

class (GenericRecordProfunctor p, GenericSumProfunctor p) => GenericNonEmptyProfunctor p Source #

A generic function using a GenericNonEmptyProfunctor works on any data type with at least one constructor.

class (GenericNonEmptyProfunctor p, GenericEmptyProfunctor p) => GenericProfunctor p Source #

A generic function using a GenericProfunctor works on any algebraic data type, including those with no constructors and constants.

data Ctor a b Source #

Constructors

Ctor 

Fields

Instances

Profunctor (Ctor *) Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> Ctor * b c -> Ctor * a d #

lmap :: (a -> b) -> Ctor * b c -> Ctor * a c #

rmap :: (b -> c) -> Ctor * a b -> Ctor * a c #

(#.) :: Coercible * c b => (b -> c) -> Ctor * a b -> Ctor * a c #

(.#) :: Coercible * b a => Ctor * b c -> (a -> b) -> Ctor * a c #

GenericEmptyProfunctor (Ctor *) Source # 

Methods

identity :: Ctor * a a Source #

zero :: Ctor * (V1 k a) (V1 k a') Source #

GenericSumProfunctor (Ctor *) Source # 

Methods

plus :: Ctor * (f a) (f' a') -> Ctor * (g a) (g' a') -> Ctor * ((k :+: f) g a) ((k :+: f') g' a') Source #

GenericProductProfunctor (Ctor *) Source # 

Methods

mult :: Ctor * (f a) (f' a') -> Ctor * (g a) (g' a') -> Ctor * ((k :*: f) g a) ((k :*: f') g' a') Source #

GenericUnitProfunctor (Ctor *) Source # 

Methods

unit :: Ctor * (U1 k a) (U1 k a') Source #

record :: forall c p t. (ADTRecord t, Constraints t c, GenericRecordProfunctor p) => (forall s. c s => p s s) -> p t t Source #

record1 :: forall c p t a b. (ADTRecord1 t, Constraints1 t c, GenericRecordProfunctor p) => (forall d e s. c s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

record01 :: forall c0 c1 p t a b. (ADTRecord1 t, Constraints01 t c0 c1, GenericRecordProfunctor p) => (forall s. c0 s => p s s) -> (forall d e s. c1 s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

nonEmpty :: forall c p t. (ADTNonEmpty t, Constraints t c, GenericNonEmptyProfunctor p) => (forall s. c s => p s s) -> p t t Source #

nonEmpty1 :: forall c p t a b. (ADTNonEmpty1 t, Constraints1 t c, GenericNonEmptyProfunctor p) => (forall d e s. c s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

nonEmpty01 :: forall c0 c1 p t a b. (ADTNonEmpty1 t, Constraints01 t c0 c1, GenericNonEmptyProfunctor p) => (forall s. c0 s => p s s) -> (forall d e s. c1 s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

generic :: forall c p t. (ADT t, Constraints t c, GenericProfunctor p) => (forall s. c s => p s s) -> p t t Source #

generic1 :: forall c p t a b. (ADT1 t, Constraints1 t c, GenericProfunctor p) => (forall d e s. c s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

generic01 :: forall c0 c1 p t a b. (ADT1 t, Constraints01 t c0 c1, GenericProfunctor p) => (forall s. c0 s => p s s) -> (forall d e s. c1 s => p d e -> p (s d) (s e)) -> p a b -> p (t a) (t b) Source #

type Constraints t c = Constraints' (Rep t) c AnyType Source #

Constraints is a constraint type synonym, containing the constraint requirements for an instance for t of class c. It requires an instance of class c for each component of t.

type Constraints01 t c0 c1 = Constraints' (Rep1 t) c0 c1 Source #

type ADTRecord t = (Generic t, ADTRecord' (Rep t), Constraints t AnyType) Source #

ADTRecord is a constraint type synonym. An instance is an ADT with *exactly* one constructor.

type ADTNonEmpty t = (Generic t, ADTNonEmpty' (Rep t), Constraints t AnyType) Source #

ADTNonEmpty is a constraint type synonym. An instance is an ADT with *at least* one constructor.

type ADT t = (Generic t, ADT' (Rep t), Constraints t AnyType) Source #

ADT is a constraint type synonym. The Generic instance can be derived, and any generic representation will be an instance of ADT' and AnyType.

ctorIndex :: ADT t => t -> Int Source #

Get the index in the lists returned by create and createA of the constructor of the given value.

For example, this is the implementation of put that generates the binary data that the above implentation of get expects:

put t = putWord8 (toEnum (ctorIndex t)) <> gfoldMap @Binary put t

ctorIndex1 :: ADT1 t => t a -> Int Source #

class AnyType (a :: k) Source #

Any type is instance of AnyType, you can use it with @AnyType if you don't actually need a class constraint.

Instances

type family FunResult t where ... Source #

The result type of a curried function.

If r is not a function type (i.e., does not unify with `_ -> _`):

FunResult (a -> r) ~ r
FunResult (a -> b -> r) ~ r
FunResult (a -> b -> c -> r) ~ r

Equations

FunResult (a -> b) = FunResult b 
FunResult r = r 

class FunConstraints c t where Source #

Automatically apply a lifted function to a polymorphic argument as many times as possible.

A constraint `FunConstraint c t` is equivalent to the conjunction of constraints `c s` for every argument type of t.

If r is not a function type:

c a :- FunConstraints c (a -> r)
(c a, c b) :- FunConstraints c (a -> b -> r)
(c a, c b, c d) :- FunConstraints c (a -> b -> d -> r)

Minimal complete definition

autoApply

Methods

autoApply :: Applicative f => (forall s. c s => f s) -> f t -> f (FunResult t) Source #

Instances

(~) * (FunResult r) r => FunConstraints c r Source # 

Methods

autoApply :: Applicative f => (forall s. c s => f s) -> f r -> f (FunResult r) Source #

(c a, FunConstraints c b) => FunConstraints c (a -> b) Source # 

Methods

autoApply :: Applicative f => (forall s. c s => f s) -> f (a -> b) -> f (FunResult (a -> b)) Source #