red-black-record-2.0.0.0: Extensible records and variants indexed by a type-level Red-Black tree.

Safe HaskellNone
LanguageHaskell2010

Data.RBR.Internal

Description

See here for the original term-level code by Stefan Kahrs. It is also copied at the end of this file. Some parts of the type-level code include the correspondign term-level parts in their comments.

Synopsis

Documentation

data Color Source #

The color of a node.

Constructors

R 
B 
Instances
Eq Color Source # 
Instance details

Defined in Data.RBR.Internal

Methods

(==) :: Color -> Color -> Bool #

(/=) :: Color -> Color -> Bool #

Show Color Source # 
Instance details

Defined in Data.RBR.Internal

Methods

showsPrec :: Int -> Color -> ShowS #

show :: Color -> String #

showList :: [Color] -> ShowS #

data Map k v Source #

The Red-Black tree. It will be used, as a kind, to index the Record and Variant types.

Constructors

E 
N Color (Map k v) k v (Map k v) 
Instances
(Eq k, Eq v) => Eq (Map k v) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

(==) :: Map k v -> Map k v -> Bool #

(/=) :: Map k v -> Map k v -> Bool #

(Show k, Show v) => Show (Map k v) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

showsPrec :: Int -> Map k v -> ShowS #

show :: Map k v -> String #

showList :: [Map k v] -> ShowS #

type EmptyMap = E Source #

A map without entries. See also unit and impossible.

type family KeysValuesAllF (c :: k -> v -> Constraint) (t :: Map k v) :: Constraint where ... Source #

Equations

KeysValuesAllF _ E = () 
KeysValuesAllF c (N color left k v right) = (c k v, KeysValuesAll c left, KeysValuesAll c right) 

class KeysValuesAllF c t => KeysValuesAll (c :: k -> v -> Constraint) (t :: Map k v) where Source #

Require a constraint for every key-value pair in a tree. This is a generalization of All from Data.SOP.

cpara_Map constructs a Record by means of a constraint for producing the nodes of the tree. The constraint is passed as a Proxy.

Methods

cpara_Map :: proxy c -> r E -> (forall left k v right color. (c k v, KeysValuesAll c left, KeysValuesAll c right) => r left -> r right -> r (N color left k v right)) -> r t Source #

Instances
KeysValuesAll (c :: k -> v -> Constraint) (E :: Map k v) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

cpara_Map :: proxy c -> r E -> (forall (left :: Map k0 v0) (k1 :: k0) (v1 :: v0) (right :: Map k0 v0) (color :: Color). (c k1 v1, KeysValuesAll c left, KeysValuesAll c right) => r left -> r right -> r (N color left k1 v1 right)) -> r E Source #

(c k2 v2, KeysValuesAll c left, KeysValuesAll c right) => KeysValuesAll (c :: k1 -> v1 -> Constraint) (N color left k2 v2 right :: Map k1 v1) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

cpara_Map :: proxy c -> r E -> (forall (left0 :: Map k v) (k :: k) (v :: v) (right0 :: Map k v) (color0 :: Color). (c k v, KeysValuesAll c left0, KeysValuesAll c right0) => r left0 -> r right0 -> r (N color0 left0 k v right0)) -> r (N color left k2 v2 right) Source #

cpure_Record :: forall c t f. KeysValuesAll c t => Proxy c -> (forall k v. c k v => f v) -> Record f t Source #

Create a Record, knowing that both keys and values satisfy a 2-place constraint. The constraint is passed as a Proxy.

The naming scheme follows that of cpure_NP.

demoteKeys :: forall t. KeysValuesAll KnownKey t => Record (K String) t Source #

Create a Record containing the names of each field.

The names are represented by a constant functor K carrying an annotation of type String. This means that there aren't actually any values of the type that corresponds to each field, only the String annotations.

class KnownSymbol k => KnownKey (k :: Symbol) (v :: z) Source #

Two-place constraint saying that the symbol can be demoted to String. Nothing is required from the value type.

Defined using the "class synonym" trick.

Instances
KnownSymbol k => KnownKey k (v :: z) Source # 
Instance details

Defined in Data.RBR.Internal

demoteEntries :: forall t. KeysValuesAll KnownKeyTypeableValue t => Record (K (String, TypeRep)) t Source #

Create a record containing the names of each field along with a term-level representation of each type.

See also collapse_Record for getting the entries as a list.

class (KnownSymbol k, Typeable v) => KnownKeyTypeableValue (k :: Symbol) (v :: Type) Source #

Two-place constraint saying that the symbol can be demoted to String, and that a term-level representation can be obtained for the value type.

Defined using the "class synonym" trick.

Instances
(KnownSymbol k, Typeable v) => KnownKeyTypeableValue k v Source # 
Instance details

Defined in Data.RBR.Internal

data Record (f :: Type -> Type) (t :: Map Symbol Type) where Source #

An extensible product-like type with named fields.

The values in the Record come wrapped in a type constructor f, which por pure records will be the identity functor I.

Constructors

Empty :: Record f E 
Node :: Record f left -> f v -> Record f right -> Record f (N color left k v right) 
Instances
(Productlike ([] :: [Type]) t result, Show (NP f result)) => Show (Record f t) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

showsPrec :: Int -> Record f t -> ShowS #

show :: Record f t -> String #

showList :: [Record f t] -> ShowS #

collapse_Record :: forall t result a. Productlike '[] t result => Record (K a) t -> [a] Source #

Collapse a Record composed of K annotations.

The naming scheme follows that of collapse_NP.

prettyShowRecord :: forall t flat f. (KeysValuesAll KnownKey t, Productlike '[] t flat, All Show flat, SListI flat) => (forall x. Show x => f x -> String) -> Record f t -> String Source #

Show a Record in a friendlier way than the default Show instance. The function argument will usually be show, but it can be used to unwrap the value of each field before showing it.

prettyShowRecordI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, All Show flat, SListI flat) => Record I t -> String Source #

Like prettyShowRecord but specialized to pure records.

unit :: Record f E Source #

A Record without components is a boring, uninformative type whose single value can be conjured out of thin air.

data Variant (f :: Type -> Type) (t :: Map Symbol Type) where Source #

An extensible sum-like type with named branches.

The values in the Variant come wrapped in a type constructor f, which por pure variants will be the identity functor I.

Constructors

Here :: f v -> Variant f (N color left k v right) 
LookRight :: Variant f t -> Variant f (N color' left' k' v' t) 
LookLeft :: Variant f t -> Variant f (N color' t k' v' right') 
Instances
(Sumlike ([] :: [Type]) t result, Show (NS f result)) => Show (Variant f t) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

showsPrec :: Int -> Variant f t -> ShowS #

show :: Variant f t -> String #

showList :: [Variant f t] -> ShowS #

impossible :: Variant f E -> b Source #

A Variant without branches doesn't have any values. From an impossible thing, anything can come out.

prettyShowVariant :: forall t flat f. (KeysValuesAll KnownKey t, Productlike '[] t flat, Sumlike '[] t flat, All Show flat, SListI flat) => (forall x. Show x => f x -> String) -> Variant f t -> String Source #

Show a Variant in a friendlier way than the default Show instance. The function argument will usually be show, but it can be used to unwrap the value of the branch before showing it.

prettyShowVariantI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, Sumlike '[] t flat, All Show flat, SListI flat) => Variant I t -> String Source #

Like prettyShowVariant but specialized to pure variants.

type family InsertAll (es :: [(Symbol, Type)]) (t :: Map Symbol Type) :: Map Symbol Type where ... Source #

Insert a list of type level key / value pairs into a type-level tree.

Equations

InsertAll '[] t = t 
InsertAll ('(name, fieldType) ': es) t = Insert name fieldType (InsertAll es t) 

type FromList (es :: [(Symbol, Type)]) = InsertAll es E Source #

Build a type-level tree out of a list of type level key / value pairs.

addField :: forall k v t f. Insertable k v t => f v -> Record f t -> Record f (Insert k v t) Source #

Alias for insert.

insertI :: forall k v t. Insertable k v t => v -> Record I t -> Record I (Insert k v t) Source #

Like insert but specialized to pure Records.

addFieldI :: forall k v t. Insertable k v t => v -> Record I t -> Record I (Insert k v t) Source #

Like addField but specialized to pure Records.

class Insertable (k :: Symbol) (v :: Type) (t :: Map Symbol Type) where Source #

Class that determines if the pair of a Symbol key and a Type can be inserted into a type-level tree.

The associated type family Insert produces the resulting tree.

At the term level, this manifests in insert, which adds a new field to a record, and in widen, which lets you use a Variant in a bigger context than the one in which is was defined. insert tends to be more useful in practice.

If the tree already has the key but with a different type, the insertion fails to compile.

Associated Types

type Insert k v t :: Map Symbol Type Source #

Methods

insert :: f v -> Record f t -> Record f (Insert k v t) Source #

widen :: Variant f t -> Variant f (Insert k v t) Source #

Instances
(InsertableHelper1 k v t, CanMakeBlack (Insert1 k v t)) => Insertable k v t Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert k v t :: Map Symbol Type Source #

Methods

insert :: f v -> Record f t -> Record f (Insert k v t) Source #

widen :: Variant f t -> Variant f (Insert k v t) Source #

class CanMakeBlack (t :: Map Symbol Type) where Source #

Associated Types

type MakeBlack t :: Map Symbol Type Source #

Instances
CanMakeBlack (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type MakeBlack E :: Map Symbol Type Source #

CanMakeBlack (N color left k v right) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type MakeBlack (N color left k v right) :: Map Symbol Type Source #

Methods

makeBlackR :: Record f (N color left k v right) -> Record f (MakeBlack (N color left k v right)) Source #

makeBlackV :: Variant f (N color left k v right) -> Variant f (MakeBlack (N color left k v right)) Source #

class InsertableHelper1 (k :: Symbol) (v :: Type) (t :: Map Symbol Type) where Source #

Associated Types

type Insert1 k v t :: Map Symbol Type Source #

Methods

insert1 :: f v -> Record f t -> Record f (Insert1 k v t) Source #

widen1 :: Variant f t -> Variant f (Insert1 k v t) Source #

Instances
InsertableHelper1 k v (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert1 k v E :: Map Symbol Type Source #

Methods

insert1 :: f v -> Record f E -> Record f (Insert1 k v E) Source #

widen1 :: Variant f E -> Variant f (Insert1 k v E) Source #

(CmpSymbol k k' ~ ordering, InsertableHelper2 ordering k v color left k' v' right) => InsertableHelper1 k v (N color left k' v' right) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert1 k v (N color left k' v' right) :: Map Symbol Type Source #

Methods

insert1 :: f v -> Record f (N color left k' v' right) -> Record f (Insert1 k v (N color left k' v' right)) Source #

widen1 :: Variant f (N color left k' v' right) -> Variant f (Insert1 k v (N color left k' v' right)) Source #

class InsertableHelper2 (ordering :: Ordering) (k :: Symbol) (v :: Type) (color :: Color) (left :: Map Symbol Type) (k' :: Symbol) (v' :: Type) (right :: Map Symbol Type) where Source #

Associated Types

type Insert2 ordering k v color left k' v' right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N color left k' v' right) -> Record f (Insert2 ordering k v color left k' v' right) Source #

widen2 :: Variant f (N color left k' v' right) -> Variant f (Insert2 ordering k v color left k' v' right) Source #

Instances
(InsertableHelper1 k v left, Balanceable (Insert1 k v left) k' v' right) => InsertableHelper2 LT k v R left k' v' right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert2 LT k v R left k' v' right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N R left k' v' right) -> Record f (Insert2 LT k v R left k' v' right) Source #

widen2 :: Variant f (N R left k' v' right) -> Variant f (Insert2 LT k v R left k' v' right) Source #

(InsertableHelper1 k v left, Balanceable (Insert1 k v left) k' v' right) => InsertableHelper2 LT k v B left k' v' right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert2 LT k v B left k' v' right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N B left k' v' right) -> Record f (Insert2 LT k v B left k' v' right) Source #

widen2 :: Variant f (N B left k' v' right) -> Variant f (Insert2 LT k v B left k' v' right) Source #

InsertableHelper2 EQ k v color left k v right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert2 EQ k v color left k v right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N color left k v right) -> Record f (Insert2 EQ k v color left k v right) Source #

widen2 :: Variant f (N color left k v right) -> Variant f (Insert2 EQ k v color left k v right) Source #

(InsertableHelper1 k v right, Balanceable left k' v' (Insert1 k v right)) => InsertableHelper2 GT k v R left k' v' right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert2 GT k v R left k' v' right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N R left k' v' right) -> Record f (Insert2 GT k v R left k' v' right) Source #

widen2 :: Variant f (N R left k' v' right) -> Variant f (Insert2 GT k v R left k' v' right) Source #

(InsertableHelper1 k v right, Balanceable left k' v' (Insert1 k v right)) => InsertableHelper2 GT k v B left k' v' right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Insert2 GT k v B left k' v' right :: Map Symbol Type Source #

Methods

insert2 :: f v -> Record f (N B left k' v' right) -> Record f (Insert2 GT k v B left k' v' right) Source #

widen2 :: Variant f (N B left k' v' right) -> Variant f (Insert2 GT k v B left k' v' right) Source #

type family ShouldBalance (left :: Map k' v') (right :: Map k' v') :: BalanceAction where ... Source #

Equations

ShouldBalance (N R _ _ _ _) (N R _ _ _ _) = BalanceSpecial 
ShouldBalance (N R (N R _ _ _ _) _ _ _) _ = BalanceLL 
ShouldBalance (N R _ _ _ (N R _ _ _ _)) _ = BalanceLR 
ShouldBalance _ (N R (N R _ _ _ _) _ _ _) = BalanceRL 
ShouldBalance _ (N R _ _ _ (N R _ _ _ _)) = BalanceRR 
ShouldBalance _ _ = DoNotBalance 

class Balanceable (left :: Map Symbol Type) (k :: Symbol) (v :: Type) (right :: Map Symbol Type) where Source #

Associated Types

type Balance left k v right :: Map Symbol Type Source #

Methods

balanceR :: Record f (N color left k v right) -> Record f (Balance left k v right) Source #

balanceV :: Variant f (N color left k v right) -> Variant f (Balance left k v right) Source #

Instances
(ShouldBalance left right ~ action, BalanceableHelper action left k v right) => Balanceable left k v right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance left k v right :: Map Symbol Type Source #

Methods

balanceR :: Record f (N color left k v right) -> Record f (Balance left k v right) Source #

balanceV :: Variant f (N color left k v right) -> Variant f (Balance left k v right) Source #

class BalanceableHelper (action :: BalanceAction) (left :: Map Symbol Type) (k :: Symbol) (v :: Type) (right :: Map Symbol Type) where Source #

Associated Types

type Balance' action left k v right :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color left k v right) -> Record f (Balance' action left k v right) Source #

balanceV' :: Variant f (N color left k v right) -> Variant f (Balance' action left k v right) Source #

Instances
BalanceableHelper DoNotBalance a k v b Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' DoNotBalance a k v b :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color a k v b) -> Record f (Balance' DoNotBalance a k v b) Source #

balanceV' :: Variant f (N color a k v b) -> Variant f (Balance' DoNotBalance a k v b) Source #

BalanceableHelper BalanceRL a k1 v1 (N R (N R b k2 v2 c) k3 v3 d) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' BalanceRL a k1 v1 (N R (N R b k2 v2 c) k3 v3 d) :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color a k1 v1 (N R (N R b k2 v2 c) k3 v3 d)) -> Record f (Balance' BalanceRL a k1 v1 (N R (N R b k2 v2 c) k3 v3 d)) Source #

balanceV' :: Variant f (N color a k1 v1 (N R (N R b k2 v2 c) k3 v3 d)) -> Variant f (Balance' BalanceRL a k1 v1 (N R (N R b k2 v2 c) k3 v3 d)) Source #

BalanceableHelper BalanceRR a k1 v1 (N R b k2 v2 (N R c k3 v3 d)) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' BalanceRR a k1 v1 (N R b k2 v2 (N R c k3 v3 d)) :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color a k1 v1 (N R b k2 v2 (N R c k3 v3 d))) -> Record f (Balance' BalanceRR a k1 v1 (N R b k2 v2 (N R c k3 v3 d))) Source #

balanceV' :: Variant f (N color a k1 v1 (N R b k2 v2 (N R c k3 v3 d))) -> Variant f (Balance' BalanceRR a k1 v1 (N R b k2 v2 (N R c k3 v3 d))) Source #

BalanceableHelper BalanceLL (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' BalanceLL (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d) -> Record f (Balance' BalanceLL (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d) Source #

balanceV' :: Variant f (N color (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d) -> Variant f (Balance' BalanceLL (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d) Source #

BalanceableHelper BalanceLR (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' BalanceLR (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d) -> Record f (Balance' BalanceLR (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d) Source #

balanceV' :: Variant f (N color (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d) -> Variant f (Balance' BalanceLR (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d) Source #

BalanceableHelper BalanceSpecial (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Balance' BalanceSpecial (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

balanceR' :: Record f (N color (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2)) -> Record f (Balance' BalanceSpecial (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2)) Source #

balanceV' :: Variant f (N color (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2)) -> Variant f (Balance' BalanceSpecial (N R left1 k1 v1 right1) kx vx (N R left2 k2 v2 right2)) Source #

type family Field (f :: Type -> Type) (t :: Map Symbol Type) (v :: Type) where ... Source #

Auxiliary type family to avoid repetition and help improve compilation times.

Equations

Field f t v = Record f t -> (f v -> Record f t, f v) 

type family Branch (f :: Type -> Type) (t :: Map Symbol Type) (v :: Type) where ... Source #

Auxiliary type family to avoid repetition and help improve compilation times.

Equations

Branch f t v = (Variant f t -> Maybe (f v), f v -> Variant f t) 

class Key (k :: Symbol) (t :: Map Symbol Type) where Source #

Class that determines if a given Symbol key is present in a type-level tree.

The Value type family gives the Type corresponding to the key.

field takes a field name (given through TypeApplications) and a Record, and returns a pair of a setter for the field and the original value of the field.

branch takes a branch name (given through TypeApplications) and returns a pair of a match function and a constructor.

Associated Types

type Value k t :: Type Source #

Methods

field :: Field f t (Value k t) Source #

branch :: Branch f t (Value k t) Source #

Instances
(CmpSymbol k' k ~ ordering, KeyHelper ordering k left v' right) => Key k (N color left k' v' right) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Value k (N color left k' v' right) :: Type Source #

Methods

field :: Field f (N color left k' v' right) (Value k (N color left k' v' right)) Source #

branch :: Branch f (N color left k' v' right) (Value k (N color left k' v' right)) Source #

class KeyHelper (ordering :: Ordering) (k :: Symbol) (left :: Map Symbol Type) (v :: Type) (right :: Map Symbol Type) where Source #

Associated Types

type Value' ordering k left v right :: Type Source #

Methods

field' :: Field f (N colorx left kx v right) (Value' ordering k left v right) Source #

branch' :: Branch f (N colorx left kx v right) (Value' ordering k left v right) Source #

Instances
KeyHelper EQ k left v right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Value' EQ k left v right :: Type Source #

Methods

field' :: Field f (N colorx left kx v right) (Value' EQ k left v right) Source #

branch' :: Branch f (N colorx left kx v right) (Value' EQ k left v right) Source #

(CmpSymbol k2 k ~ ordering, KeyHelper ordering k left2 v2 right2) => KeyHelper LT k left v (N color2 left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Value' LT k left v (N color2 left2 k2 v2 right2) :: Type Source #

Methods

field' :: Field f (N colorx left kx v (N color2 left2 k2 v2 right2)) (Value' LT k left v (N color2 left2 k2 v2 right2)) Source #

branch' :: Branch f (N colorx left kx v (N color2 left2 k2 v2 right2)) (Value' LT k left v (N color2 left2 k2 v2 right2)) Source #

(CmpSymbol k2 k ~ ordering, KeyHelper ordering k left2 v2 right2) => KeyHelper GT k (N color2 left2 k2 v2 right2) v' right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Value' GT k (N color2 left2 k2 v2 right2) v' right :: Type Source #

Methods

field' :: Field f (N colorx (N color2 left2 k2 v2 right2) kx v' right) (Value' GT k (N color2 left2 k2 v2 right2) v' right) Source #

branch' :: Branch f (N colorx (N color2 left2 k2 v2 right2) kx v' right) (Value' GT k (N color2 left2 k2 v2 right2) v' right) Source #

project :: forall k t f. Key k t => Record f t -> f (Value k t) Source #

Get the value of a field for a Record.

getField :: forall k t f. Key k t => Record f t -> f (Value k t) Source #

Alias for project.

setField :: forall k t f. Key k t => f (Value k t) -> Record f t -> Record f t Source #

Set the value of a field for a Record.

modifyField :: forall k t f. Key k t => (f (Value k t) -> f (Value k t)) -> Record f t -> Record f t Source #

Modify the value of a field for a Record.

inject :: forall k t f. Key k t => f (Value k t) -> Variant f t Source #

Put a value into the branch of a Variant.

match :: forall k t f. Key k t => Variant f t -> Maybe (f (Value k t)) Source #

Check if a Variant value is the given branch.

projectI :: forall k t. Key k t => Record I t -> Value k t Source #

Like project but specialized to pure Records.

getFieldI :: forall k t. Key k t => Record I t -> Value k t Source #

Like getField but specialized to pure Records.

setFieldI :: forall k t. Key k t => Value k t -> Record I t -> Record I t Source #

Like setField but specialized to pure Records.

modifyFieldI :: forall k t. Key k t => (Value k t -> Value k t) -> Record I t -> Record I t Source #

Like modifyField but specialized to pure Records.

injectI :: forall k t. Key k t => Value k t -> Variant I t Source #

Like inject but specialized to pure Variants.

matchI :: forall k t. Key k t => Variant I t -> Maybe (Value k t) Source #

Like match but specialized to pure Variantss.

eliminate :: (Productlike '[] t result, Sumlike '[] t result, SListI result) => Record (Case f r) t -> Variant f t -> r Source #

Process a Variant using a eliminator Record that carries handlers for each possible branch of the Variant.

newtype Case f a b Source #

Represents a handler for a branch of a Variant.

Constructors

Case (f b -> a) 

addCase :: forall k v t f a. Insertable k v t => (f v -> a) -> Record (Case f a) t -> Record (Case f a) (Insert k v t) Source #

A form of addField for creating eliminators for Variants.

addCaseI :: forall k v t a. Insertable k v t => (v -> a) -> Record (Case I a) t -> Record (Case I a) (Insert k v t) Source #

A pure version of addCase.

newtype SetField f a b Source #

Constructors

SetField 

Fields

class (Key k t, Value k t ~ v) => PresentIn (t :: Map Symbol Type) (k :: Symbol) (v :: Type) Source #

Instances
(Key k t, Value k t ~ v) => PresentIn t k v Source # 
Instance details

Defined in Data.RBR.Internal

type ProductlikeSubset (subset :: Map Symbol Type) (whole :: Map Symbol Type) (flat :: [Type]) = (KeysValuesAll (PresentIn whole) subset, Productlike '[] subset flat, SListI flat) Source #

Constraint for trees that represent subsets of fields of Record-like types.

fieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> (Record f subset -> Record f whole, Record f subset) Source #

Like field, but targets multiple fields at the same time

projectSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset Source #

Like project, but extracts multiple fields at the same time.

Can also be used to convert between structurally dissimilar trees that nevertheless have the same entries.

getFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset Source #

Alias for projectSubset.

setFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f subset -> Record f whole -> Record f whole Source #

Like setField, but sets multiple fields at the same time.

modifyFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => (Record f subset -> Record f subset) -> Record f whole -> Record f whole Source #

Like modifyField, but modifies multiple fields at the same time.

type SumlikeSubset (subset :: Map Symbol Type) (whole :: Map Symbol Type) (subflat :: [Type]) (wholeflat :: [Type]) = (KeysValuesAll (PresentIn whole) subset, Productlike '[] whole wholeflat, Sumlike '[] whole wholeflat, SListI wholeflat, Productlike '[] subset subflat, Sumlike '[] subset subflat, SListI subflat) Source #

Constraint for trees that represent subsets of branches of Variant-like types.

branchSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => (Variant f whole -> Maybe (Variant f subset), Variant f subset -> Variant f whole) Source #

Like branch, but targets multiple branches at the same time.

injectSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f subset -> Variant f whole Source #

Like inject, but injects one of several possible branches.

matchSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f whole -> Maybe (Variant f subset) Source #

Like match, but matches more than one branch.

eliminateSubset :: forall subset whole subflat wholeflat f r. SumlikeSubset subset whole subflat wholeflat => Record (Case f r) whole -> Variant f subset -> r Source #

Like eliminate, but allows the eliminator Record to have more fields than there are branches in the Variant.

class Productlike (start :: [Type]) (t :: Map Symbol Type) (result :: [Type]) | start t -> result, result t -> start where Source #

Class from converting Records to and from the n-ary product type NP from Data.SOP.

prefixNP flattens a Record and adds it to the initial part of the product.

breakNP reconstructs a Record from the initial part of the product and returns the unconsumed part.

The functions toNP and fromNP are usually easier to use.

Methods

prefixNP :: Record f t -> NP f start -> NP f result Source #

breakNP :: NP f result -> (Record f t, NP f start) Source #

Instances
Productlike start (E :: Map Symbol Type) start Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNP :: Record f E -> NP f start -> NP f start Source #

breakNP :: NP f start -> (Record f E, NP f start) Source #

(Productlike start right middle, Productlike (v ': middle) left result) => Productlike start (N color left k v right) result Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNP :: Record f (N color left k v right) -> NP f start -> NP f result Source #

breakNP :: NP f result -> (Record f (N color left k v right), NP f start) Source #

toNP :: forall t result f. Productlike '[] t result => Record f t -> NP f result Source #

Convert a Record into a n-ary product.

fromNP :: forall t result f. Productlike '[] t result => NP f result -> Record f t Source #

Convert a n-ary product into a compatible Record.

class Sumlike (start :: [Type]) (t :: Map Symbol Type) (result :: [Type]) | start t -> result, result t -> start where Source #

Class from converting Variants to and from the n-ary sum type NS from Data.SOP.

prefixNS flattens a Variant and adds it to the initial part of the sum.

breakNS reconstructs a Variant from the initial part of the sum and returns the unconsumed part.

The functions toNS and fromNS are usually easier to use.

Methods

prefixNS :: Either (NS f start) (Variant f t) -> NS f result Source #

breakNS :: NS f result -> Either (NS f start) (Variant f t) Source #

Instances
Sumlike (v ': start) (N colorL leftL kL vL rightL) result => Sumlike start (N color (N colorL leftL kL vL rightL) k v (E :: Map Symbol Type)) result Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNS :: Either (NS f start) (Variant f (N color (N colorL leftL kL vL rightL) k v E)) -> NS f result Source #

breakNS :: NS f result -> Either (NS f start) (Variant f (N color (N colorL leftL kL vL rightL) k v E)) Source #

(Sumlike start (N colorR leftR kR vR rightR) middle, Sumlike (v ': middle) (N colorL leftL kL vL rightL) result) => Sumlike start (N color (N colorL leftL kL vL rightL) k v (N colorR leftR kR vR rightR)) result Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNS :: Either (NS f start) (Variant f (N color (N colorL leftL kL vL rightL) k v (N colorR leftR kR vR rightR))) -> NS f result Source #

breakNS :: NS f result -> Either (NS f start) (Variant f (N color (N colorL leftL kL vL rightL) k v (N colorR leftR kR vR rightR))) Source #

Sumlike start (N colorR leftR kR vR rightR) middle => Sumlike start (N color (E :: Map Symbol Type) k v (N colorR leftR kR vR rightR)) (v ': middle) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNS :: Either (NS f start) (Variant f (N color E k v (N colorR leftR kR vR rightR))) -> NS f (v ': middle) Source #

breakNS :: NS f (v ': middle) -> Either (NS f start) (Variant f (N color E k v (N colorR leftR kR vR rightR))) Source #

Sumlike start (N color (E :: Map Symbol Type) k v (E :: Map Symbol Type)) (v ': start) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

prefixNS :: Either (NS f start) (Variant f (N color E k v E)) -> NS f (v ': start) Source #

breakNS :: NS f (v ': start) -> Either (NS f start) (Variant f (N color E k v E)) Source #

toNS :: forall t result f. Sumlike '[] t result => Variant f t -> NS f result Source #

Convert a Variant into a n-ary sum.

fromNS :: forall t result f. Sumlike '[] t result => NS f result -> Variant f t Source #

Convert a n-ary sum into a compatible Variant.

class ToRecord (r :: Type) where Source #

Minimal complete definition

Nothing

Associated Types

type RecordCode r :: Map Symbol Type Source #

class ToRecordHelper (start :: Map Symbol Type) (g :: Type -> Type) where Source #

Associated Types

type RecordCode' start g :: Map Symbol Type Source #

Methods

toRecord' :: Record I start -> g x -> Record I (RecordCode' start g) Source #

Instances
(ToRecordHelper start t2, RecordCode' start t2 ~ middle, ToRecordHelper middle t1) => ToRecordHelper start (t1 :*: t2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type RecordCode' start (t1 :*: t2) :: Map Symbol Type Source #

Methods

toRecord' :: Record I start -> (t1 :*: t2) x -> Record I (RecordCode' start (t1 :*: t2)) Source #

Insertable k v start => ToRecordHelper start (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v)) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type RecordCode' start (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v)) :: Map Symbol Type Source #

Methods

toRecord' :: Record I start -> S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v) x -> Record I (RecordCode' start (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v))) Source #

ToRecordHelper (E :: Map Symbol Type) fields => ToRecordHelper (E :: Map Symbol Type) (D1 meta (C1 metacons fields)) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type RecordCode' E (D1 meta (C1 metacons fields)) :: Map Symbol Type Source #

Methods

toRecord' :: Record I E -> D1 meta (C1 metacons fields) x -> Record I (RecordCode' E (D1 meta (C1 metacons fields))) Source #

class ToRecord r => FromRecord (r :: Type) where Source #

Minimal complete definition

Nothing

class FromRecordHelper (t :: Map Symbol Type) (g :: Type -> Type) where Source #

Methods

fromRecord' :: Record I t -> g x Source #

Instances
(FromRecordHelper t t1, FromRecordHelper t t2) => FromRecordHelper t (t1 :*: t2) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromRecord' :: Record I t -> (t1 :*: t2) x Source #

(Key k t, Value k t ~ v) => FromRecordHelper t (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v)) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromRecord' :: Record I t -> S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v) x Source #

FromRecordHelper t fields => FromRecordHelper t (D1 meta (C1 metacons fields)) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromRecord' :: Record I t -> D1 meta (C1 metacons fields) x Source #

type family VariantCode (s :: Type) :: Map Symbol Type where ... Source #

Equations

VariantCode s = VariantCode' E (Rep s) 

type family VariantCode' (acc :: Map Symbol Type) (g :: Type -> Type) :: Map Symbol Type where ... Source #

Equations

VariantCode' acc (D1 meta fields) = VariantCode' acc fields 
VariantCode' acc (t1 :+: t2) = VariantCode' (VariantCode' acc t2) t1 
VariantCode' acc (C1 (MetaCons k _ _) (S1 (MetaSel Nothing unpackedness strictness laziness) (Rec0 v))) = Insert k v acc 

class FromVariant (s :: Type) where Source #

Minimal complete definition

Nothing

class FromVariantHelper (t :: Map Symbol Type) (g :: Type -> Type) where Source #

Methods

fromVariant' :: Variant I t -> Maybe (g x) Source #

Instances
(FromVariantHelper t t1, FromVariantHelper t t2) => FromVariantHelper t (t1 :+: t2) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromVariant' :: Variant I t -> Maybe ((t1 :+: t2) x) Source #

(Key k t, Value k t ~ v) => FromVariantHelper t (C1 (MetaCons k x y) (S1 (MetaSel (Nothing :: Maybe Symbol) unpackedness strictness laziness) (Rec0 v))) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromVariant' :: Variant I t -> Maybe (C1 (MetaCons k x y) (S1 (MetaSel Nothing unpackedness strictness laziness) (Rec0 v)) x0) Source #

FromVariantHelper t fields => FromVariantHelper t (D1 meta fields) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

fromVariant' :: Variant I t -> Maybe (D1 meta fields x) Source #

class ToVariant (s :: Type) where Source #

Minimal complete definition

Nothing

class ToVariantHelper (t :: Map Symbol Type) (g :: Type -> Type) where Source #

Methods

toVariant' :: g x -> Variant I t Source #

Instances
(ToVariantHelper t t1, ToVariantHelper t t2) => ToVariantHelper t (t1 :+: t2) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

toVariant' :: (t1 :+: t2) x -> Variant I t Source #

(Key k t, Value k t ~ v) => ToVariantHelper t (C1 (MetaCons k x y) (S1 (MetaSel (Nothing :: Maybe Symbol) unpackedness strictness laziness) (Rec0 v))) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

toVariant' :: C1 (MetaCons k x y) (S1 (MetaSel Nothing unpackedness strictness laziness) (Rec0 v)) x0 -> Variant I t Source #

ToVariantHelper t fields => ToVariantHelper t (D1 meta fields) Source # 
Instance details

Defined in Data.RBR.Internal

Methods

toVariant' :: D1 meta fields x -> Variant I t Source #

type family DiscriminateBalL (l :: Map k v) (r :: Map k v) :: Bool where ... Source #

Equations

DiscriminateBalL (N R _ _ _ _) _ = False 
DiscriminateBalL _ _ = True 

class BalanceableL (l :: Map Symbol Type) (k :: Symbol) (v :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type BalL l k v r :: Map Symbol Type Source #

Methods

balLR :: Record f (N color l k v r) -> Record f (BalL l k v r) Source #

balLV :: Variant f (N color l k v r) -> Variant f (BalL l k v r) Source #

Instances
(DiscriminateBalL l r ~ b, BalanceableHelperL b l k v r) => BalanceableL l k v r Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalL l k v r :: Map Symbol Type Source #

Methods

balLR :: Record f (N color l k v r) -> Record f (BalL l k v r) Source #

balLV :: Variant f (N color l k v r) -> Variant f (BalL l k v r) Source #

class BalanceableHelperL (b :: Bool) (l :: Map Symbol Type) (k :: Symbol) (v :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type BalL' b l k v r :: Map Symbol Type Source #

Methods

balLR' :: Record f (N color l k v r) -> Record f (BalL' b l k v r) Source #

balLV' :: Variant f (N color l k v r) -> Variant f (BalL' b l k v r) Source #

Instances
BalanceableHelper (ShouldBalance t3 (N R l k kv r)) t3 z zv (N R l k kv r) => BalanceableHelperL True t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r)) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalL' True t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r)) :: Map Symbol Type Source #

Methods

balLR' :: Record f (N color t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r))) -> Record f (BalL' True t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r))) Source #

balLV' :: Variant f (N color t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r))) -> Variant f (BalL' True t1 y yv (N R (N B t2 u uv t3) z zv (N B l k kv r))) Source #

BalanceableHelper (ShouldBalance t1 (N R t2 z zv t3)) t1 y yv (N R t2 z zv t3) => BalanceableHelperL True t1 y yv (N B t2 z zv t3) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalL' True t1 y yv (N B t2 z zv t3) :: Map Symbol Type Source #

Methods

balLR' :: Record f (N color t1 y yv (N B t2 z zv t3)) -> Record f (BalL' True t1 y yv (N B t2 z zv t3)) Source #

balLV' :: Variant f (N color t1 y yv (N B t2 z zv t3)) -> Variant f (BalL' True t1 y yv (N B t2 z zv t3)) Source #

BalanceableHelperL False (N R left1 k1 v1 right1) k2 v2 right2 Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalL' False (N R left1 k1 v1 right1) k2 v2 right2 :: Map Symbol Type Source #

Methods

balLR' :: Record f (N color (N R left1 k1 v1 right1) k2 v2 right2) -> Record f (BalL' False (N R left1 k1 v1 right1) k2 v2 right2) Source #

balLV' :: Variant f (N color (N R left1 k1 v1 right1) k2 v2 right2) -> Variant f (BalL' False (N R left1 k1 v1 right1) k2 v2 right2) Source #

type family DiscriminateBalR (l :: Map k v) (r :: Map k v) :: Bool where ... Source #

Equations

DiscriminateBalR _ (N R _ _ _ _) = False 
DiscriminateBalR _ _ = True 

class BalanceableR (l :: Map Symbol Type) (k :: Symbol) (v :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type BalR l k v r :: Map Symbol Type Source #

Methods

balRR :: Record f (N color l k v r) -> Record f (BalR l k v r) Source #

balRV :: Variant f (N color l k v r) -> Variant f (BalR l k v r) Source #

Instances
(DiscriminateBalR l r ~ b, BalanceableHelperR b l k v r) => BalanceableR l k v r Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalR l k v r :: Map Symbol Type Source #

Methods

balRR :: Record f (N color l k v r) -> Record f (BalR l k v r) Source #

balRV :: Variant f (N color l k v r) -> Variant f (BalR l k v r) Source #

class BalanceableHelperR (b :: Bool) (l :: Map Symbol Type) (k :: Symbol) (v :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type BalR' b l k v r :: Map Symbol Type Source #

Methods

balRR' :: Record f (N color l k v r) -> Record f (BalR' b l k v r) Source #

balRV' :: Variant f (N color l k v r) -> Variant f (BalR' b l k v r) Source #

Instances
BalanceableHelperR False right2 k2 v2 (N R left1 k1 v1 right1) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalR' False right2 k2 v2 (N R left1 k1 v1 right1) :: Map Symbol Type Source #

Methods

balRR' :: Record f (N color right2 k2 v2 (N R left1 k1 v1 right1)) -> Record f (BalR' False right2 k2 v2 (N R left1 k1 v1 right1)) Source #

balRV' :: Variant f (N color right2 k2 v2 (N R left1 k1 v1 right1)) -> Variant f (BalR' False right2 k2 v2 (N R left1 k1 v1 right1)) Source #

BalanceableHelper (ShouldBalance (N R t2 u uv t3) l) (N R t2 u uv t3) z zv l => BalanceableHelperR True (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1 Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalR' True (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1 :: Map Symbol Type Source #

Methods

balRR' :: Record f (N color (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1) -> Record f (BalR' True (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1) Source #

balRV' :: Variant f (N color (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1) -> Variant f (BalR' True (N R (N B t2 u uv t3) z zv (N B l k kv r)) y yv t1) Source #

BalanceableHelper (ShouldBalance (N R t2 z zv t3) t1) (N R t2 z zv t3) y yv t1 => BalanceableHelperR True (N B t2 z zv t3) y yv t1 Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type BalR' True (N B t2 z zv t3) y yv t1 :: Map Symbol Type Source #

Methods

balRR' :: Record f (N color (N B t2 z zv t3) y yv t1) -> Record f (BalR' True (N B t2 z zv t3) y yv t1) Source #

balRV' :: Variant f (N color (N B t2 z zv t3) y yv t1) -> Variant f (BalR' True (N B t2 z zv t3) y yv t1) Source #

class Fuseable (l :: Map Symbol Type) (r :: Map Symbol Type) where Source #

Associated Types

type Fuse l r :: Map Symbol Type Source #

Methods

fuseRecord :: Record f l -> Record f r -> Record f (Fuse l r) Source #

fuseVariant :: Either (Variant f l) (Variant f r) -> Variant f (Fuse l r) Source #

Instances
Fuseable (E :: Map Symbol Type) (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse E E :: Map Symbol Type Source #

Fuseable (E :: Map Symbol Type) (N color left k v right) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse E (N color left k v right) :: Map Symbol Type Source #

Methods

fuseRecord :: Record f E -> Record f (N color left k v right) -> Record f (Fuse E (N color left k v right)) Source #

fuseVariant :: Either (Variant f E) (Variant f (N color left k v right)) -> Variant f (Fuse E (N color left k v right)) Source #

Fuseable (N color left k v right) (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse (N color left k v right) E :: Map Symbol Type Source #

Methods

fuseRecord :: Record f (N color left k v right) -> Record f E -> Record f (Fuse (N color left k v right) E) Source #

fuseVariant :: Either (Variant f (N color left k v right)) (Variant f E) -> Variant f (Fuse (N color left k v right) E) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ fused, FuseableHelper1 fused (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) => Fuseable (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord :: Record f (N R left1 k1 v1 right1) -> Record f (N R left2 k2 v2 right2) -> Record f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

fuseVariant :: Either (Variant f (N R left1 k1 v1 right1)) (Variant f (N R left2 k2 v2 right2)) -> Variant f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

Fuseable right1 (N B left2 k2 v2 right2) => Fuseable (N R left1 k1 v1 right1) (N B left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse (N R left1 k1 v1 right1) (N B left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord :: Record f (N R left1 k1 v1 right1) -> Record f (N B left2 k2 v2 right2) -> Record f (Fuse (N R left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

fuseVariant :: Either (Variant f (N R left1 k1 v1 right1)) (Variant f (N B left2 k2 v2 right2)) -> Variant f (Fuse (N R left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ fused, FuseableHelper2 fused (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) => Fuseable (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord :: Record f (N B left1 k1 v1 right1) -> Record f (N B left2 k2 v2 right2) -> Record f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

fuseVariant :: Either (Variant f (N B left1 k1 v1 right1)) (Variant f (N B left2 k2 v2 right2)) -> Variant f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

Fuseable (N B left1 k1 v1 right1) left2 => Fuseable (N B left1 k1 v1 right1) (N R left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse (N B left1 k1 v1 right1) (N R left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord :: Record f (N B left1 k1 v1 right1) -> Record f (N R left2 k2 v2 right2) -> Record f (Fuse (N B left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

fuseVariant :: Either (Variant f (N B left1 k1 v1 right1)) (Variant f (N R left2 k2 v2 right2)) -> Variant f (Fuse (N B left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

class FuseableHelper1 (fused :: Map Symbol Type) (l :: Map Symbol Type) (r :: Map Symbol Type) where Source #

Associated Types

type Fuse1 fused l r :: Map Symbol Type Source #

Methods

fuseRecord1 :: Record f l -> Record f r -> Record f (Fuse l r) Source #

fuseVariant1 :: Either (Variant f l) (Variant f r) -> Variant f (Fuse l r) Source #

Instances
FuseableHelper1 (E :: Map Symbol Type) (N R left1 k1 v1 (E :: Map Symbol Type)) (N R (E :: Map Symbol Type) k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse1 E (N R left1 k1 v1 E) (N R E k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord1 :: Record f (N R left1 k1 v1 E) -> Record f (N R E k2 v2 right2) -> Record f (Fuse (N R left1 k1 v1 E) (N R E k2 v2 right2)) Source #

fuseVariant1 :: Either (Variant f (N R left1 k1 v1 E)) (Variant f (N R E k2 v2 right2)) -> Variant f (Fuse (N R left1 k1 v1 E) (N R E k2 v2 right2)) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ N R s1 z zv s2) => FuseableHelper1 (N R s1 z zv s2) (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse1 (N R s1 z zv s2) (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord1 :: Record f (N R left1 k1 v1 right1) -> Record f (N R left2 k2 v2 right2) -> Record f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

fuseVariant1 :: Either (Variant f (N R left1 k1 v1 right1)) (Variant f (N R left2 k2 v2 right2)) -> Variant f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ N B s1 z zv s2) => FuseableHelper1 (N B s1 z zv s2) (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse1 (N B s1 z zv s2) (N R left1 k1 v1 right1) (N R left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord1 :: Record f (N R left1 k1 v1 right1) -> Record f (N R left2 k2 v2 right2) -> Record f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

fuseVariant1 :: Either (Variant f (N R left1 k1 v1 right1)) (Variant f (N R left2 k2 v2 right2)) -> Variant f (Fuse (N R left1 k1 v1 right1) (N R left2 k2 v2 right2)) Source #

class FuseableHelper2 (fused :: Map Symbol Type) (l :: Map Symbol Type) (r :: Map Symbol Type) where Source #

Associated Types

type Fuse2 fused l r :: Map Symbol Type Source #

Methods

fuseRecord2 :: Record f l -> Record f r -> Record f (Fuse l r) Source #

fuseVariant2 :: Either (Variant f l) (Variant f r) -> Variant f (Fuse l r) Source #

Instances
BalanceableL left1 k1 v1 (N B (E :: Map Symbol Type) k2 v2 right2) => FuseableHelper2 (E :: Map Symbol Type) (N B left1 k1 v1 (E :: Map Symbol Type)) (N B (E :: Map Symbol Type) k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse2 E (N B left1 k1 v1 E) (N B E k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord2 :: Record f (N B left1 k1 v1 E) -> Record f (N B E k2 v2 right2) -> Record f (Fuse (N B left1 k1 v1 E) (N B E k2 v2 right2)) Source #

fuseVariant2 :: Either (Variant f (N B left1 k1 v1 E)) (Variant f (N B E k2 v2 right2)) -> Variant f (Fuse (N B left1 k1 v1 E) (N B E k2 v2 right2)) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ N R s1 z zv s2) => FuseableHelper2 (N R s1 z zv s2) (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse2 (N R s1 z zv s2) (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord2 :: Record f (N B left1 k1 v1 right1) -> Record f (N B left2 k2 v2 right2) -> Record f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

fuseVariant2 :: Either (Variant f (N B left1 k1 v1 right1)) (Variant f (N B left2 k2 v2 right2)) -> Variant f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

(Fuseable right1 left2, Fuse right1 left2 ~ N B s1 z zv s2, BalanceableL left1 k1 v1 (N B (N B s1 z zv s2) k2 v2 right2)) => FuseableHelper2 (N B s1 z zv s2) (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Fuse2 (N B s1 z zv s2) (N B left1 k1 v1 right1) (N B left2 k2 v2 right2) :: Map Symbol Type Source #

Methods

fuseRecord2 :: Record f (N B left1 k1 v1 right1) -> Record f (N B left2 k2 v2 right2) -> Record f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

fuseVariant2 :: Either (Variant f (N B left1 k1 v1 right1)) (Variant f (N B left2 k2 v2 right2)) -> Variant f (Fuse (N B left1 k1 v1 right1) (N B left2 k2 v2 right2)) Source #

class Delable (k :: Symbol) (v :: Type) (t :: Map Symbol Type) where Source #

Associated Types

type Del k v t :: Map Symbol Type Source #

Methods

del :: Record f t -> Record f (Del k v t) Source #

win :: Variant f t -> Either (Variant f (Del k v t)) (f v) Source #

Instances
Delable k v (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Del k v E :: Map Symbol Type Source #

Methods

del :: Record f E -> Record f (Del k v E) Source #

win :: Variant f E -> Either (Variant f (Del k v E)) (f v) Source #

(CmpSymbol kx k ~ ordering, DelableHelper ordering k v left kx vx right) => Delable k v (N color left kx vx right) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Del k v (N color left kx vx right) :: Map Symbol Type Source #

Methods

del :: Record f (N color left kx vx right) -> Record f (Del k v (N color left kx vx right)) Source #

win :: Variant f (N color left kx vx right) -> Either (Variant f (Del k v (N color left kx vx right))) (f v) Source #

class DelableL (k :: Symbol) (v :: Type) (l :: Map Symbol Type) (kx :: Symbol) (vx :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type DelL k v l kx vx r :: Map Symbol Type Source #

Methods

delL :: Record f (N color l kx vx r) -> Record f (DelL k v l kx vx r) Source #

winL :: Variant f (N color l kx vx r) -> Either (Variant f (DelL k v l kx vx r)) (f v) Source #

Instances
DelableL k v (E :: Map Symbol Type) kx vx right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelL k v E kx vx right :: Map Symbol Type Source #

Methods

delL :: Record f (N color E kx vx right) -> Record f (DelL k v E kx vx right) Source #

winL :: Variant f (N color E kx vx right) -> Either (Variant f (DelL k v E kx vx right)) (f v) Source #

Delable k v (N R leftz kz vz rightz) => DelableL k v (N R leftz kz vz rightz) kx vx right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelL k v (N R leftz kz vz rightz) kx vx right :: Map Symbol Type Source #

Methods

delL :: Record f (N color (N R leftz kz vz rightz) kx vx right) -> Record f (DelL k v (N R leftz kz vz rightz) kx vx right) Source #

winL :: Variant f (N color (N R leftz kz vz rightz) kx vx right) -> Either (Variant f (DelL k v (N R leftz kz vz rightz) kx vx right)) (f v) Source #

(Delable k v (N B leftz kz vz rightz), BalanceableL (Del k v (N B leftz kz vz rightz)) kx vx right) => DelableL k v (N B leftz kz vz rightz) kx vx right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelL k v (N B leftz kz vz rightz) kx vx right :: Map Symbol Type Source #

Methods

delL :: Record f (N color (N B leftz kz vz rightz) kx vx right) -> Record f (DelL k v (N B leftz kz vz rightz) kx vx right) Source #

winL :: Variant f (N color (N B leftz kz vz rightz) kx vx right) -> Either (Variant f (DelL k v (N B leftz kz vz rightz) kx vx right)) (f v) Source #

class DelableR (k :: Symbol) (v :: Type) (l :: Map Symbol Type) (kx :: Symbol) (vx :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type DelR k v l kx vx r :: Map Symbol Type Source #

Methods

delR :: Record f (N color l kx vx r) -> Record f (DelR k v l kx vx r) Source #

winR :: Variant f (N color l kx vx r) -> Either (Variant f (DelR k v l kx vx r)) (f v) Source #

Instances
DelableR k v left kx vx (E :: Map Symbol Type) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelR k v left kx vx E :: Map Symbol Type Source #

Methods

delR :: Record f (N color left kx vx E) -> Record f (DelR k v left kx vx E) Source #

winR :: Variant f (N color left kx vx E) -> Either (Variant f (DelR k v left kx vx E)) (f v) Source #

Delable k v (N R leftz kz vz rightz) => DelableR k v left kx vx (N R leftz kz vz rightz) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelR k v left kx vx (N R leftz kz vz rightz) :: Map Symbol Type Source #

Methods

delR :: Record f (N color left kx vx (N R leftz kz vz rightz)) -> Record f (DelR k v left kx vx (N R leftz kz vz rightz)) Source #

winR :: Variant f (N color left kx vx (N R leftz kz vz rightz)) -> Either (Variant f (DelR k v left kx vx (N R leftz kz vz rightz))) (f v) Source #

(Delable k v (N B leftz kz vz rightz), BalanceableR left kx vx (Del k v (N B leftz kz vz rightz))) => DelableR k v left kx vx (N B leftz kz vz rightz) Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type DelR k v left kx vx (N B leftz kz vz rightz) :: Map Symbol Type Source #

Methods

delR :: Record f (N color left kx vx (N B leftz kz vz rightz)) -> Record f (DelR k v left kx vx (N B leftz kz vz rightz)) Source #

winR :: Variant f (N color left kx vx (N B leftz kz vz rightz)) -> Either (Variant f (DelR k v left kx vx (N B leftz kz vz rightz))) (f v) Source #

class DelableHelper (ordering :: Ordering) (k :: Symbol) (v :: Type) (l :: Map Symbol Type) (kx :: Symbol) (vx :: Type) (r :: Map Symbol Type) where Source #

Associated Types

type Del' ordering k v l kx vx r :: Map Symbol Type Source #

Methods

del' :: Record f (N color l kx vx r) -> Record f (Del' ordering k v l kx vx r) Source #

win' :: Variant f (N color l kx vx r) -> Either (Variant f (Del' ordering k v l kx vx r)) (f v) Source #

Instances
DelableR k v left kx vx right => DelableHelper LT k v left kx vx right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Del' LT k v left kx vx right :: Map Symbol Type Source #

Methods

del' :: Record f (N color left kx vx right) -> Record f (Del' LT k v left kx vx right) Source #

win' :: Variant f (N color left kx vx right) -> Either (Variant f (Del' LT k v left kx vx right)) (f v) Source #

Fuseable left right => DelableHelper EQ k v left k v right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Del' EQ k v left k v right :: Map Symbol Type Source #

Methods

del' :: Record f (N color left k v right) -> Record f (Del' EQ k v left k v right) Source #

win' :: Variant f (N color left k v right) -> Either (Variant f (Del' EQ k v left k v right)) (f v) Source #

DelableL k v left kx vx right => DelableHelper GT k v left kx vx right Source # 
Instance details

Defined in Data.RBR.Internal

Associated Types

type Del' GT k v left kx vx right :: Map Symbol Type Source #

Methods

del' :: Record f (N color left kx vx right) -> Record f (Del' GT k v left kx vx right) Source #

win' :: Variant f (N color left kx vx right) -> Either (Variant f (Del' GT k v left kx vx right)) (f v) Source #

class Deletable (k :: Symbol) (v :: Type) (t :: Map Symbol Type) where Source #

Associated Types

type Delete k v t :: Map Symbol Type Source #

Methods

delete :: Record f t -> Record f (Delete k v t) Source #

winnow :: Variant f t -> Either (Variant f (Delete k v t)) (f v) Source #

Instances
(Delable k v t, CanMakeBlack (Del k v t)) => Deletable k v t Source #

Class that determines if the pair of a Symbol key and a Type can be deleted from a type-level tree.

The associated type family Delete produces the resulting tree.

At the term level, this manifests in delete, which removes a field from a record, and in winnow, which checks if a Variant is of a given branch and returns the value in the branch if there's a match, or a reduced Variant if there isn't.

winnow tends to be more useful in practice.

If the tree already has the key but with a different type, the deletion fails to compile.

Instance details

Defined in Data.RBR.Internal

Associated Types

type Delete k v t :: Map Symbol Type Source #

Methods

delete :: Record f t -> Record f (Delete k v t) Source #

winnow :: Variant f t -> Either (Variant f (Delete k v t)) (f v) Source #

winnowI :: forall k v t. Deletable k v t => Variant I t -> Either (Variant I (Delete k v t)) v Source #

Like winnow but specialized to pure Variants.