row-types-0.3.0.0: Open Records and Variants

Safe HaskellNone
LanguageHaskell98

Data.Row.Internal

Contents

Description

This module implements the internals of open records and variants.

Synopsis

Rows

newtype Row a Source #

The kind of rows. This type is only used as a datakind. A row is a typelevel entity telling us which symbols are associated with which types.

Constructors

R [LT a]

A row is a list of symbol-to-type pairs that should always be sorted lexically by the symbol. The constructor is exported here (because this is an internal module) but should not be exported elsewhere.

data Label (s :: Symbol) Source #

A label

Constructors

Label 
Instances
x y => IsLabel x (Label y) Source # 
Instance details

Defined in Data.Row.Internal

Methods

fromLabel :: Label y #

Eq (Label s) Source # 
Instance details

Defined in Data.Row.Internal

Methods

(==) :: Label s -> Label s -> Bool #

(/=) :: Label s -> Label s -> Bool #

KnownSymbol s => Show (Label s) Source # 
Instance details

Defined in Data.Row.Internal

Methods

showsPrec :: Int -> Label s -> ShowS #

show :: Label s -> String #

showList :: [Label s] -> ShowS #

class KnownSymbol (n :: Symbol) #

This class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.

Since: base-4.7.0.0

Minimal complete definition

symbolSing

data LT a Source #

The kind of elements of rows. Each element is a label and its associated type.

Constructors

Symbol :-> a 
Instances
(KnownSymbol ℓ, c τ1 τ2, BiForall (R ρ1) (R ρ2) c) => BiForall (R ((ℓ :-> τ1) ': ρ1) :: Row k1) (R ((ℓ :-> τ2) ': ρ2) :: Row k2) (c :: k1 -> k2 -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

biMetamorph :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ0 :: Symbol) (τ10 :: k10) (τ20 :: k20) (ρ10 :: [LT k10]) (ρ20 :: [LT k20]). (KnownSymbol ℓ0, c τ10 τ20) => Label ℓ0 -> f (R ((ℓ0 :-> τ10) ': ρ10)) (R ((ℓ0 :-> τ20) ': ρ20)) -> (h τ10 τ20, f (R ρ10) (R ρ20))) -> (forall (ℓ1 :: Symbol) (τ11 :: k10) (τ21 :: k20) (ρ11 :: [LT k10]) (ρ21 :: [LT k20]). (KnownSymbol ℓ1, c τ11 τ21) => Label ℓ1 -> h τ11 τ21 -> g (R ρ11) (R ρ21) -> g (R ((ℓ1 :-> τ11) ': ρ11)) (R ((ℓ1 :-> τ21) ': ρ21))) -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) Source #

biMetamorph' :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ0 :: Symbol) (τ10 :: k10) (τ20 :: k20) (ρ10 :: [LT k10]) (ρ20 :: [LT k20]). (KnownSymbol ℓ0, c τ10 τ20) => Label ℓ0 -> f (R ((ℓ0 :-> τ10) ': ρ10)) (R ((ℓ0 :-> τ20) ': ρ20)) -> Either (h τ10 τ20) (f (R ρ10) (R ρ20))) -> (forall (ℓ1 :: Symbol) (τ11 :: k10) (τ21 :: k20) (ρ11 :: [LT k10]) (ρ21 :: [LT k20]). (KnownSymbol ℓ1, c τ11 τ21) => Label ℓ1 -> Either (h τ11 τ21) (g (R ρ11) (R ρ21)) -> g (R ((ℓ1 :-> τ11) ': ρ11)) (R ((ℓ1 :-> τ21) ': ρ21))) -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) Source #

BiForall (R ([] :: [LT k1]) :: Row k1) (R ([] :: [LT k2]) :: Row k2) (c1 :: k1 -> k2 -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

biMetamorph :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> (h τ1 τ2, f (R ρ1) (R ρ2))) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> h τ1 τ2 -> g (R ρ1) (R ρ2) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f (R []) (R []) -> g (R []) (R []) Source #

biMetamorph' :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> Either (h τ1 τ2) (f (R ρ1) (R ρ2))) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> Either (h τ1 τ2) (g (R ρ1) (R ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f (R []) (R []) -> g (R []) (R []) Source #

(KnownSymbol ℓ, c τ, Forall (R ρ) c) => Forall (R ((ℓ :-> τ) ': ρ) :: Row k) (c :: k -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

metamorph :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ0 :: Symbol) (τ0 :: k0) (ρ0 :: [LT k0]). (KnownSymbol ℓ0, c τ0) => Label ℓ0 -> f (R ((ℓ0 :-> τ0) ': ρ0)) -> (h τ0, f (R ρ0))) -> (forall (ℓ1 :: Symbol) (τ1 :: k0) (ρ1 :: [LT k0]). (KnownSymbol ℓ1, c τ1) => Label ℓ1 -> h τ1 -> g (R ρ1) -> g (R ((ℓ1 :-> τ1) ': ρ1))) -> f (R ((ℓ :-> τ) ': ρ)) -> g (R ((ℓ :-> τ) ': ρ)) Source #

metamorph' :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ0 :: Symbol) (τ0 :: k0) (ρ0 :: [LT k0]). (KnownSymbol ℓ0, c τ0) => Label ℓ0 -> f (R ((ℓ0 :-> τ0) ': ρ0)) -> Either (h τ0) (f (R ρ0))) -> (forall (ℓ1 :: Symbol) (τ1 :: k0) (ρ1 :: [LT k0]). (KnownSymbol ℓ1, c τ1) => Label ℓ1 -> Either (h τ1) (g (R ρ1)) -> g (R ((ℓ1 :-> τ1) ': ρ1))) -> f (R ((ℓ :-> τ) ': ρ)) -> g (R ((ℓ :-> τ) ': ρ)) Source #

Forall (R ([] :: [LT k]) :: Row k) (c :: k -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

metamorph :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> (h τ, f (R ρ))) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> h τ -> g (R ρ) -> g (R ((ℓ :-> τ) ': ρ))) -> f (R []) -> g (R []) Source #

metamorph' :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> Either (h τ) (f (R ρ))) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> Either (h τ) (g (R ρ)) -> g (R ((ℓ :-> τ) ': ρ))) -> f (R []) -> g (R []) Source #

(KnownSymbol l, Switch (R v) (R r) b) => Switch (R ((l :-> a) ': v)) (R ((l :-> (a -> b)) ': r)) b Source # 
Instance details

Defined in Data.Row.Switch

Methods

switch :: Var (R ((l :-> a) ': v)) -> Rec (R ((l :-> (a -> b)) ': r)) -> b Source #

caseon :: Rec (R ((l :-> (a -> b)) ': r)) -> Var (R ((l :-> a) ': v)) -> b Source #

Switch (R ([] :: [LT Type])) (R ([] :: [LT Type])) x Source # 
Instance details

Defined in Data.Row.Switch

Methods

switch :: Var (R []) -> Rec (R []) -> x Source #

caseon :: Rec (R []) -> Var (R []) -> x Source #

type Empty = R '[] Source #

Type level version of empty

data HideType where Source #

Elements stored in a Row type are usually hidden.

Constructors

HideType :: a -> HideType 

Row Operations

type family Extend (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ... Source #

Type level Row extension

Equations

Extend l a (R x) = R (Inject (l :-> a) x) 

type family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ... Source #

Type level Row modification

Equations

Modify l a (R ρ) = R (ModifyR l a ρ) 

type family Rename (l :: Symbol) (l' :: Symbol) (r :: Row k) :: Row k where ... Source #

Type level row renaming

Equations

Rename l l' r = Extend l' (r .! l) (r .- l) 

type (.==) (l :: Symbol) (a :: k) = Extend l a Empty infix 7 Source #

A type level way to create a singleton Row.

type family (r :: Row k) .! (t :: Symbol) :: k where ... infixl 5 Source #

Type level label fetching

Equations

(R r) .! l = Get l r 

type family (r :: Row k) .- (s :: Symbol) :: Row k where ... infixl 6 Source #

Type level Row element removal

Equations

(R r) .- l = R (Remove l r) 

type family (l :: Row k) .\\ (r :: Row k) :: Row k where ... infixl 6 Source #

Type level Row difference. That is, l .\\ r is the row remaining after removing any matching elements of r from l.

Equations

(R l) .\\ (R r) = R (Diff l r) 

Various row-type merges

The difference between .+ (read "append"), .\/ (read "min-join"), and .\\ (read "const-union") comes down to how duplicates are handled. In .+, the two given row-types must be entirely unique. Even the same entry in both row-types is forbidden. In .\/, this final restriction is relaxed, allowing two row-types that have no conflicts to be merged in the logical way. The .\\ operator is the most liberal, allowing any two row-types to be merged together, and whenever there is a conflict, favoring the left argument.

As examples of use:

  • .+ is used when appending two records, assuring that those two records are entirely disjoint.
  • .\/ is used when diversifying a variant, allowing some extension to the row-type so long as no original types have changed.
  • .// is used when doing record overwrite, allowing data in a record to totally overwrite what was previously there.

type family (l :: Row k) .+ (r :: Row k) :: Row k where ... infixl 6 Source #

Type level Row append

Equations

(R l) .+ (R r) = R (Merge l r) 

type family (l :: Row k) .\/ (r :: Row k) where ... infixl 6 Source #

The minimum join of the two rows.

Equations

(R l) .\/ (R r) = R (MinJoinR l r) 

type family (l :: Row k) .// (r :: Row k) where ... infixl 6 Source #

The overwriting union, where the left row overwrites the types of the right row where the labels overlap.

Equations

(R l) .// (R r) = R (ConstUnionR l r) 

Row Constraints

class Lacks (l :: Symbol) (r :: Row *) Source #

Alias for .\. It is a class rather than an alias, so that it can be partially applied.

Instances
r .\ l => Lacks l r Source # 
Instance details

Defined in Data.Row.Internal

type family (r :: Row k) .\ (l :: Symbol) :: Constraint where ... infixl 4 Source #

Does the row lack (i.e. it does not have) the specified label?

Equations

(R r) .\ l = LacksR l r r 

class (r .! l) a => HasType l a r Source #

Alias for (r .! l) ≈ a. It is a class rather than an alias, so that it can be partially applied.

Instances
(r .! l) a => HasType l (a :: k) (r :: Row k) Source # 
Instance details

Defined in Data.Row.Internal

class Forall (r :: Row k) (c :: k -> Constraint) where Source #

Any structure over a row in which every element is similarly constrained can be metamorphized into another structure over the same row.

Methods

metamorph Source #

Arguments

:: forall (f :: Row k -> *) (g :: Row k -> *) (h :: k -> *). Proxy h 
-> (f Empty -> g Empty)

The way to transform the empty element

-> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> (h τ, f (R ρ)))

The unfold

-> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> h τ -> g (R ρ) -> g (R ((ℓ :-> τ) ': ρ)))

The fold

-> f r

The input structure

-> g r 

A metamorphism is an unfold followed by a fold. This one is for product-like row-types (e.g. Rec).

metamorph' Source #

Arguments

:: forall (f :: Row k -> *) (g :: Row k -> *) (h :: k -> *). Proxy h 
-> (f Empty -> g Empty)

The way to transform the empty element

-> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> Either (h τ) (f (R ρ)))

The unfold

-> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> Either (h τ) (g (R ρ)) -> g (R ((ℓ :-> τ) ': ρ)))

The fold

-> f r

The input structure

-> g r 

A metamorphism is an unfold followed by a fold. This one is for sum-like row-types (e.g. Var).

Instances
(KnownSymbol ℓ, c τ, Forall (R ρ) c) => Forall (R ((ℓ :-> τ) ': ρ) :: Row k) (c :: k -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

metamorph :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ0 :: Symbol) (τ0 :: k0) (ρ0 :: [LT k0]). (KnownSymbol ℓ0, c τ0) => Label ℓ0 -> f (R ((ℓ0 :-> τ0) ': ρ0)) -> (h τ0, f (R ρ0))) -> (forall (ℓ1 :: Symbol) (τ1 :: k0) (ρ1 :: [LT k0]). (KnownSymbol ℓ1, c τ1) => Label ℓ1 -> h τ1 -> g (R ρ1) -> g (R ((ℓ1 :-> τ1) ': ρ1))) -> f (R ((ℓ :-> τ) ': ρ)) -> g (R ((ℓ :-> τ) ': ρ)) Source #

metamorph' :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ0 :: Symbol) (τ0 :: k0) (ρ0 :: [LT k0]). (KnownSymbol ℓ0, c τ0) => Label ℓ0 -> f (R ((ℓ0 :-> τ0) ': ρ0)) -> Either (h τ0) (f (R ρ0))) -> (forall (ℓ1 :: Symbol) (τ1 :: k0) (ρ1 :: [LT k0]). (KnownSymbol ℓ1, c τ1) => Label ℓ1 -> Either (h τ1) (g (R ρ1)) -> g (R ((ℓ1 :-> τ1) ': ρ1))) -> f (R ((ℓ :-> τ) ': ρ)) -> g (R ((ℓ :-> τ) ': ρ)) Source #

Forall (R ([] :: [LT k]) :: Row k) (c :: k -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

metamorph :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> (h τ, f (R ρ))) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> h τ -> g (R ρ) -> g (R ((ℓ :-> τ) ': ρ))) -> f (R []) -> g (R []) Source #

metamorph' :: Proxy h -> (f Empty -> g Empty) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> f (R ((ℓ :-> τ) ': ρ)) -> Either (h τ) (f (R ρ))) -> (forall (ℓ :: Symbol) (τ :: k0) (ρ :: [LT k0]). (KnownSymbol ℓ, c τ) => Label ℓ -> Either (h τ) (g (R ρ)) -> g (R ((ℓ :-> τ) ': ρ))) -> f (R []) -> g (R []) Source #

class BiForall (r1 :: Row k1) (r2 :: Row k2) (c :: k1 -> k2 -> Constraint) where Source #

Any structure over two rows in which the elements of each row satisfy some constraints can be metamorphized into another structure over both of the rows.

Methods

biMetamorph :: forall (f :: Row k1 -> Row k2 -> *) (g :: Row k1 -> Row k2 -> *) (h :: k1 -> k2 -> *). Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> (h τ1 τ2, f (R ρ1) (R ρ2))) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> h τ1 τ2 -> g (R ρ1) (R ρ2) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f r1 r2 -> g r1 r2 Source #

A metamorphism is a fold followed by an unfold. This one is for product-like row-types.

biMetamorph' :: forall (f :: Row k1 -> Row k2 -> *) (g :: Row k1 -> Row k2 -> *) (h :: k1 -> k2 -> *). Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> Either (h τ1 τ2) (f (R ρ1) (R ρ2))) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> Either (h τ1 τ2) (g (R ρ1) (R ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f r1 r2 -> g r1 r2 Source #

A metamorphism is a fold followed by an unfold. This one is for sum-like row-types.

Instances
(KnownSymbol ℓ, c τ1 τ2, BiForall (R ρ1) (R ρ2) c) => BiForall (R ((ℓ :-> τ1) ': ρ1) :: Row k1) (R ((ℓ :-> τ2) ': ρ2) :: Row k2) (c :: k1 -> k2 -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

biMetamorph :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ0 :: Symbol) (τ10 :: k10) (τ20 :: k20) (ρ10 :: [LT k10]) (ρ20 :: [LT k20]). (KnownSymbol ℓ0, c τ10 τ20) => Label ℓ0 -> f (R ((ℓ0 :-> τ10) ': ρ10)) (R ((ℓ0 :-> τ20) ': ρ20)) -> (h τ10 τ20, f (R ρ10) (R ρ20))) -> (forall (ℓ1 :: Symbol) (τ11 :: k10) (τ21 :: k20) (ρ11 :: [LT k10]) (ρ21 :: [LT k20]). (KnownSymbol ℓ1, c τ11 τ21) => Label ℓ1 -> h τ11 τ21 -> g (R ρ11) (R ρ21) -> g (R ((ℓ1 :-> τ11) ': ρ11)) (R ((ℓ1 :-> τ21) ': ρ21))) -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) Source #

biMetamorph' :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ0 :: Symbol) (τ10 :: k10) (τ20 :: k20) (ρ10 :: [LT k10]) (ρ20 :: [LT k20]). (KnownSymbol ℓ0, c τ10 τ20) => Label ℓ0 -> f (R ((ℓ0 :-> τ10) ': ρ10)) (R ((ℓ0 :-> τ20) ': ρ20)) -> Either (h τ10 τ20) (f (R ρ10) (R ρ20))) -> (forall (ℓ1 :: Symbol) (τ11 :: k10) (τ21 :: k20) (ρ11 :: [LT k10]) (ρ21 :: [LT k20]). (KnownSymbol ℓ1, c τ11 τ21) => Label ℓ1 -> Either (h τ11 τ21) (g (R ρ11) (R ρ21)) -> g (R ((ℓ1 :-> τ11) ': ρ11)) (R ((ℓ1 :-> τ21) ': ρ21))) -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) Source #

BiForall (R ([] :: [LT k1]) :: Row k1) (R ([] :: [LT k2]) :: Row k2) (c1 :: k1 -> k2 -> Constraint) Source # 
Instance details

Defined in Data.Row.Internal

Methods

biMetamorph :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> (h τ1 τ2, f (R ρ1) (R ρ2))) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> h τ1 τ2 -> g (R ρ1) (R ρ2) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f (R []) (R []) -> g (R []) (R []) Source #

biMetamorph' :: Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> f (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2)) -> Either (h τ1 τ2) (f (R ρ1) (R ρ2))) -> (forall (ℓ :: Symbol) (τ1 :: k10) (τ2 :: k20) (ρ1 :: [LT k10]) (ρ2 :: [LT k20]). (KnownSymbol ℓ, c1 τ1 τ2) => Label ℓ -> Either (h τ1 τ2) (g (R ρ1) (R ρ2)) -> g (R ((ℓ :-> τ1) ': ρ1)) (R ((ℓ :-> τ2) ': ρ2))) -> f (R []) (R []) -> g (R []) (R []) Source #

class (c1 x, c2 y) => BiConstraint c1 c2 x y Source #

A pair of constraints

Instances
(c1 x, c2 y) => BiConstraint (c1 :: k2 -> Constraint) (c2 :: k1 -> Constraint) (x :: k2) (y :: k1) Source # 
Instance details

Defined in Data.Row.Internal

class Unconstrained1 a Source #

A null constraint of one argument

Instances
Unconstrained1 (a :: k) Source # 
Instance details

Defined in Data.Row.Internal

class Unconstrained2 a b Source #

A null constraint of two arguments

Instances
Unconstrained2 (a :: k2) (b :: k1) Source # 
Instance details

Defined in Data.Row.Internal

type WellBehaved ρ = (Forall ρ Unconstrained1, AllUniqueLabels ρ) Source #

A convenient way to provide common, easy constraints

type family AllUniqueLabels (r :: Row k) :: Constraint where ... Source #

Are all of the labels in this Row unique?

Equations

AllUniqueLabels (R r) = AllUniqueLabelsR r 

type family Ap (fs :: Row (a -> b)) (r :: Row a) :: Row b where ... Source #

Take two rows with the same labels, and apply the type operator from the first row to the type of the second.

Equations

Ap (R fs) (R r) = R (ApR fs r) 

type family Zip (r1 :: Row *) (r2 :: Row *) where ... Source #

Zips two rows together to create a Row of the pairs. The two rows must have the same set of labels.

Equations

Zip (R r1) (R r2) = R (ZipR r1 r2) 

type family Map (f :: a -> b) (r :: Row a) :: Row b where ... Source #

Map a type level function over a Row.

Equations

Map f (R r) = R (MapR f r) 

type family Subset (r1 :: Row k) (r2 :: Row k) :: Constraint where ... Source #

Is the first row a subset of the second?

Equations

Subset (R r1) (R r2) = SubsetR r1 r2 

type Disjoint l r = (WellBehaved l, WellBehaved r, Subset l (l .+ r), Subset r (l .+ r), ((l .+ r) .\\ l) r, ((l .+ r) .\\ r) l) Source #

A type synonym for disjointness.

Helper functions

type family Labels (r :: Row a) where ... Source #

The labels in a Row.

Equations

Labels (R '[]) = '[] 
Labels (R ((l :-> a) ': xs)) = l ': Labels (R xs) 

labels :: forall ρ c s. (IsString s, Forall ρ c) => [s] Source #

Return a list of the labels in a row type.

labels' :: forall ρ s. (IsString s, Forall ρ Unconstrained1) => [s] Source #

Return a list of the labels in a row type and is specialized to the Unconstrained1 constraint.

show' :: (IsString s, Show a) => a -> s Source #

A helper function for showing labels

toKey :: forall s. KnownSymbol s => Label s -> Text Source #

A helper function to turn a Label directly into Text.

type (≈) a b = a ~ b infix 4 Source #

A lower fixity operator for type equality

mapForall :: forall f c ρ. Forall ρ c :- Forall (Map f ρ) (IsA c f) Source #

This allows us to derive a `Forall (Map f r) ..` from a `Forall r ..`.

freeForall :: forall r c. Forall r c :- Forall r Unconstrained1 Source #

Allow any Forall over a row-type, be usable for Unconstrained1.

uniqueMap :: forall f ρ. AllUniqueLabels ρ :- AllUniqueLabels (Map f ρ) Source #

Map preserves uniqueness of labels.

mapHas :: forall f r l t. ((r .! l) t) :- ((Map f r .! l) f t) Source #

This allows us to derive `Map f r .! l ≈ f t` from `r .! l ≈ t`

class IsA c f a where Source #

A class to capture the idea of As so that it can be partially applied in a context.

Methods

as :: As c f a Source #

Instances
c a => IsA (c :: k2 -> Constraint) (f :: k2 -> k1) (f a :: k1) Source # 
Instance details

Defined in Data.Row.Internal

Methods

as :: As c f (f a) Source #

data As c f a where Source #

This data type is used to for its ability to existentially bind a type variable. Particularly, it says that for the type a, there exists a t such that 'a ~ f t' and 'c t' holds.

Constructors

As :: forall c f a t. (a ~ f t, c t) => As c f a