Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Color
- data RBT k v
- type family KeysValuesAllF (c :: k -> v -> Constraint) (t :: RBT k v) :: Constraint where ...
- class KeysValuesAllF c t => KeysValuesAll (c :: k -> v -> Constraint) (t :: RBT k v) where
- cpara_RBT :: 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
- demoteKeys :: forall t. KeysValuesAll KnownKey t => Record (K String) t
- class KnownSymbol k => KnownKey (k :: Symbol) (v :: z)
- data Record (f :: Type -> Type) (t :: RBT Symbol Type) where
- 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
- prettyShowRecordI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, All Show flat, SListI flat) => Record I t -> String
- unit :: Record f E
- data Variant (f :: Type -> Type) (t :: RBT Symbol Type) where
- impossible :: Variant f E -> b
- 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
- prettyShowVariantI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, Sumlike '[] t flat, All Show flat, SListI flat) => Variant I t -> String
- type family InsertAll (es :: [(Symbol, Type)]) (t :: RBT Symbol Type) :: RBT Symbol Type where ...
- type FromList (es :: [(Symbol, Type)]) = InsertAll es E
- addField :: forall k v t f. Insertable k v t => f v -> Record f t -> Record f (Insert k v t)
- insertI :: forall k v t. Insertable k v t => v -> Record I t -> Record I (Insert k v t)
- addFieldI :: forall k v t. Insertable k v t => v -> Record I t -> Record I (Insert k v t)
- class Insertable (k :: Symbol) (v :: Type) (t :: RBT Symbol Type) where
- class CanMakeBlack (t :: RBT Symbol Type) where
- class InsertableHelper1 (k :: Symbol) (v :: Type) (t :: RBT Symbol Type) where
- class InsertableHelper2 (ordering :: Ordering) (k :: Symbol) (v :: Type) (color :: Color) (left :: RBT Symbol Type) (k' :: Symbol) (v' :: Type) (right :: RBT Symbol Type) where
- data BalanceAction
- type family ShouldBalance (color :: Color) (left :: RBT k' v') (right :: RBT k' v') :: BalanceAction where ...
- class Balanceable (color :: Color) (left :: RBT Symbol Type) (k :: Symbol) (v :: Type) (right :: RBT Symbol Type) where
- class BalanceableHelper (action :: BalanceAction) (color :: Color) (left :: RBT Symbol Type) (k :: Symbol) (v :: Type) (right :: RBT Symbol Type) where
- class Key (k :: Symbol) (t :: RBT Symbol Type) where
- class KeyHelper (ordering :: Ordering) (k :: Symbol) (t :: RBT Symbol Type) where
- project :: forall k t f. Key k t => Record f t -> f (Value k t)
- getField :: forall k t f. Key k t => Record f t -> f (Value k t)
- setField :: forall k t f. Key k t => f (Value k t) -> Record f t -> Record f t
- modifyField :: forall k t f. Key k t => (f (Value k t) -> f (Value k t)) -> Record f t -> Record f t
- inject :: forall k t f. Key k t => f (Value k t) -> Variant f t
- match :: forall k t f. Key k t => Variant f t -> Maybe (f (Value k t))
- projectI :: forall k t. Key k t => Record I t -> Value k t
- getFieldI :: forall k t. Key k t => Record I t -> Value k t
- setFieldI :: forall k t. Key k t => Value k t -> Record I t -> Record I t
- modifyFieldI :: forall k t. Key k t => (Value k t -> Value k t) -> Record I t -> Record I t
- injectI :: forall k t. Key k t => Value k t -> Variant I t
- matchI :: forall k t. Key k t => Variant I t -> Maybe (Value k t)
- eliminate :: (Productlike '[] t result, Sumlike '[] t result, SListI result) => Record (Case f r) t -> Variant f t -> r
- newtype Case f a b = 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)
- 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)
- newtype SetField f a b = SetField {
- getSetField :: f b -> a -> a
- class (Key k t, Value k t ~ v) => PresentIn (t :: RBT Symbol Type) (k :: Symbol) (v :: Type)
- type ProductlikeSubset (subset :: RBT Symbol Type) (whole :: RBT Symbol Type) (flat :: [Type]) = (KeysValuesAll (PresentIn whole) subset, Productlike '[] subset flat, SListI flat)
- fieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> (Record f subset -> Record f whole, Record f subset)
- projectSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset
- getFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset
- setFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f subset -> Record f whole -> Record f whole
- modifyFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => (Record f subset -> Record f subset) -> Record f whole -> Record f whole
- type SumlikeSubset (subset :: RBT Symbol Type) (whole :: RBT 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)
- 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)
- injectSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f subset -> Variant f whole
- matchSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f whole -> Maybe (Variant f subset)
- eliminateSubset :: forall subset whole subflat wholeflat f r. SumlikeSubset subset whole subflat wholeflat => Record (Case f r) whole -> Variant f subset -> r
- class Productlike (start :: [Type]) (t :: RBT Symbol Type) (result :: [Type]) | start t -> result, result t -> start where
- toNP :: forall t result f. Productlike '[] t result => Record f t -> NP f result
- fromNP :: forall t result f. Productlike '[] t result => NP f result -> Record f t
- class Sumlike (start :: [Type]) (t :: RBT Symbol Type) (result :: [Type]) | start t -> result, result t -> start where
- toNS :: forall t result f. Sumlike '[] t result => Variant f t -> NS f result
- fromNS :: forall t result f. Sumlike '[] t result => NS f result -> Variant f t
- class ToRecord (r :: Type) where
- type RecordCode r :: RBT Symbol Type
- toRecord :: r -> Record I (RecordCode r)
- class ToRecordHelper (start :: RBT Symbol Type) (g :: Type -> Type) where
- type RecordCode' start g :: RBT Symbol Type
- toRecord' :: Record I start -> g x -> Record I (RecordCode' start g)
- class ToRecord r => FromRecord (r :: Type) where
- fromRecord :: Record I (RecordCode r) -> r
- class FromRecordHelper (t :: RBT Symbol Type) (g :: Type -> Type) where
- fromRecord' :: Record I t -> g x
- type family VariantCode (s :: Type) :: RBT Symbol Type where ...
- type family VariantCode' (acc :: RBT Symbol Type) (g :: Type -> Type) :: RBT Symbol Type where ...
- class FromVariant (s :: Type) where
- fromVariant :: Variant I (VariantCode s) -> s
- class FromVariantHelper (t :: RBT Symbol Type) (g :: Type -> Type) where
- fromVariant' :: Variant I t -> Maybe (g x)
- class ToVariant (s :: Type) where
- toVariant :: s -> Variant I (VariantCode s)
- class ToVariantHelper (t :: RBT Symbol Type) (g :: Type -> Type) where
- toVariant' :: g x -> Variant I t
Documentation
The color of a node.
type family KeysValuesAllF (c :: k -> v -> Constraint) (t :: RBT k v) :: Constraint where ... Source #
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 :: RBT 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_RBT
constructs a Record
by means of a constraint for producing
the nodes of the tree. The constraint is passed as a Proxy
.
This function seldom needs to be called directly.
cpara_RBT :: 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 :: RBT k v) Source # | |
Defined in Data.RBR.Internal | |
(c k2 v2, KeysValuesAll c left, KeysValuesAll c right) => KeysValuesAll (c :: k1 -> v1 -> Constraint) (N color left k2 v2 right :: RBT k1 v1) Source # | |
Defined in Data.RBR.Internal |
demoteKeys :: forall t. KeysValuesAll KnownKey t => Record (K String) t Source #
class KnownSymbol k => KnownKey (k :: Symbol) (v :: z) Source #
Instances
KnownSymbol k => KnownKey k (v :: z) Source # | |
Defined in Data.RBR.Internal |
data Record (f :: Type -> Type) (t :: RBT 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
.
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 #
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.
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 :: RBT 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
.
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 #
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 :: RBT Symbol Type) :: RBT Symbol Type where ... Source #
Insert a list of type level key / value pairs into a type-level tree.
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
.
class Insertable (k :: Symbol) (v :: Type) (t :: RBT 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.
class CanMakeBlack (t :: RBT Symbol Type) where Source #
makeBlackR :: Record f t -> Record f (MakeBlack t) Source #
makeBlackV :: Variant f t -> Variant f (MakeBlack t) Source #
Instances
CanMakeBlack (N color left k v right) Source # | |
Defined in Data.RBR.Internal |
class InsertableHelper1 (k :: Symbol) (v :: Type) (t :: RBT Symbol Type) where Source #
Instances
InsertableHelper1 k v (E :: RBT Symbol Type) Source # | |
(CmpSymbol k k' ~ ordering, InsertableHelper2 ordering k v color left k' v' right) => InsertableHelper1 k v (N color left k' v' right) Source # | |
Defined in Data.RBR.Internal |
class InsertableHelper2 (ordering :: Ordering) (k :: Symbol) (v :: Type) (color :: Color) (left :: RBT Symbol Type) (k' :: Symbol) (v' :: Type) (right :: RBT Symbol Type) where Source #
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 color (Insert1 k v left) k' v' right) => InsertableHelper2 LT k v color left k' v' right Source # | |
Defined in Data.RBR.Internal | |
InsertableHelper2 EQ k v color left k v right Source # | |
Defined in Data.RBR.Internal | |
(InsertableHelper1 k v right, Balanceable color left k' v' (Insert1 k v right)) => InsertableHelper2 GT k v color left k' v' right Source # | |
Defined in Data.RBR.Internal |
data BalanceAction Source #
Instances
Show BalanceAction Source # | |
Defined in Data.RBR.Internal showsPrec :: Int -> BalanceAction -> ShowS # show :: BalanceAction -> String # showList :: [BalanceAction] -> ShowS # |
type family ShouldBalance (color :: Color) (left :: RBT k' v') (right :: RBT k' v') :: BalanceAction where ... Source #
ShouldBalance B (N R (N R _ _ _ _) _ _ _) _ = BalanceLL | |
ShouldBalance B (N R _ _ _ (N R _ _ _ _)) _ = BalanceLR | |
ShouldBalance B _ (N R (N R _ _ _ _) _ _ _) = BalanceRL | |
ShouldBalance B _ (N R _ _ _ (N R _ _ _ _)) = BalanceRR | |
ShouldBalance _ _ _ = DoNotBalance |
class Balanceable (color :: Color) (left :: RBT Symbol Type) (k :: Symbol) (v :: Type) (right :: RBT Symbol Type) where Source #
balanceR :: Record f (N color left k v right) -> Record f (Balance color left k v right) Source #
balanceV :: Variant f (N color left k v right) -> Variant f (Balance color left k v right) Source #
Instances
(ShouldBalance color left right ~ action, BalanceableHelper action color left k v right) => Balanceable color left k v right Source # | |
class BalanceableHelper (action :: BalanceAction) (color :: Color) (left :: RBT Symbol Type) (k :: Symbol) (v :: Type) (right :: RBT Symbol Type) where Source #
balanceR' :: Record f (N color left k v right) -> Record f (Balance' action color left k v right) Source #
balanceV' :: Variant f (N color left k v right) -> Variant f (Balance' action color left k v right) Source #
Instances
BalanceableHelper DoNotBalance color a k v b Source # | |
BalanceableHelper BalanceRL B a k1 v1 (N R (N R b k2 v2 c) k3 v3 d) Source # | |
Defined in Data.RBR.Internal | |
BalanceableHelper BalanceRR B a k1 v1 (N R b k2 v2 (N R c k3 v3 d)) Source # | |
Defined in Data.RBR.Internal | |
BalanceableHelper BalanceLL B (N R (N R a k1 v1 b) k2 v2 c) k3 v3 d Source # | |
Defined in Data.RBR.Internal | |
BalanceableHelper BalanceLR B (N R a k1 v1 (N R b k2 v2 c)) k3 v3 d Source # | |
Defined in Data.RBR.Internal |
class Key (k :: Symbol) (t :: RBT 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.
field :: Record f t -> (f (Value k t) -> Record f t, f (Value k t)) Source #
branch :: (Variant f t -> Maybe (f (Value k t)), f (Value k t) -> Variant f t) Source #
Instances
(CmpSymbol k' k ~ ordering, KeyHelper ordering k (N color left k' v' right)) => Key k (N color left k' v' right) Source # | |
Defined in Data.RBR.Internal field :: Record f (N color left k' v' right) -> (f (Value k (N color left k' v' right)) -> Record f (N color left k' v' right), f (Value k (N color left k' v' right))) Source # branch :: (Variant f (N color left k' v' right) -> Maybe (f (Value k (N color left k' v' right))), f (Value k (N color left k' v' right)) -> Variant f (N color left k' v' right)) Source # |
class KeyHelper (ordering :: Ordering) (k :: Symbol) (t :: RBT Symbol Type) where Source #
field' :: Record f t -> (f (Value' ordering k t) -> Record f t, f (Value' ordering k t)) Source #
branch' :: (Variant f t -> Maybe (f (Value' ordering k t)), f (Value' ordering k t) -> Variant f t) Source #
Instances
Key k right => KeyHelper LT k (N color left k' v' right) Source # | |
Defined in Data.RBR.Internal field' :: Record f (N color left k' v' right) -> (f (Value' LT k (N color left k' v' right)) -> Record f (N color left k' v' right), f (Value' LT k (N color left k' v' right))) Source # branch' :: (Variant f (N color left k' v' right) -> Maybe (f (Value' LT k (N color left k' v' right))), f (Value' LT k (N color left k' v' right)) -> Variant f (N color left k' v' right)) Source # | |
KeyHelper EQ k (N color left k v right) Source # | |
Defined in Data.RBR.Internal field' :: Record f (N color left k v right) -> (f (Value' EQ k (N color left k v right)) -> Record f (N color left k v right), f (Value' EQ k (N color left k v right))) Source # branch' :: (Variant f (N color left k v right) -> Maybe (f (Value' EQ k (N color left k v right))), f (Value' EQ k (N color left k v right)) -> Variant f (N color left k v right)) Source # | |
Key k left => KeyHelper GT k (N color left k' v' right) Source # | |
Defined in Data.RBR.Internal field' :: Record f (N color left k' v' right) -> (f (Value' GT k (N color left k' v' right)) -> Record f (N color left k' v' right), f (Value' GT k (N color left k' v' right))) Source # branch' :: (Variant f (N color left k' v' right) -> Maybe (f (Value' GT k (N color left k' v' right))), f (Value' GT k (N color left k' v' right)) -> Variant f (N color left k' 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
.
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.
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 Record
s.
matchI :: forall k t. Key k t => Variant I t -> Maybe (Value k t) Source #
Like match
but specialized to pure Variants
s.
eliminate :: (Productlike '[] t result, Sumlike '[] t result, SListI result) => Record (Case f r) t -> Variant f t -> r Source #
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 #
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 #
SetField | |
|
class (Key k t, Value k t ~ v) => PresentIn (t :: RBT Symbol Type) (k :: Symbol) (v :: Type) Source #
type ProductlikeSubset (subset :: RBT Symbol Type) (whole :: RBT 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 :: RBT Symbol Type) (whole :: RBT 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 #
class Productlike (start :: [Type]) (t :: RBT Symbol Type) (result :: [Type]) | start t -> result, result t -> start where Source #
Class from converting Record
s 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.
Instances
Productlike start (E :: RBT Symbol Type) start Source # | |
(Productlike start right middle, Productlike (v ': middle) left result) => Productlike start (N color left k v right) result 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 :: RBT Symbol Type) (result :: [Type]) | start t -> result, result t -> start where Source #
Class from converting Variant
s 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.
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 :: RBT Symbol Type)) result 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 # | |
Defined in Data.RBR.Internal | |
Sumlike start (N colorR leftR kR vR rightR) middle => Sumlike start (N color (E :: RBT Symbol Type) k v (N colorR leftR kR vR rightR)) (v ': middle) Source # | |
Sumlike start (N color (E :: RBT Symbol Type) k v (E :: RBT Symbol Type)) (v ': start) 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 #
Nothing
toRecord :: r -> Record I (RecordCode r) Source #
toRecord :: (Generic r, ToRecordHelper E (Rep r), RecordCode r ~ RecordCode' E (Rep r)) => r -> Record I (RecordCode r) Source #
class ToRecordHelper (start :: RBT Symbol Type) (g :: Type -> Type) where Source #
Instances
(ToRecordHelper start t2, RecordCode' start t2 ~ middle, ToRecordHelper middle t1) => ToRecordHelper start (t1 :*: t2) Source # | |
Insertable k v start => ToRecordHelper start (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v)) Source # | |
ToRecordHelper (E :: RBT Symbol Type) fields => ToRecordHelper (E :: RBT Symbol Type) (D1 meta (C1 metacons fields)) Source # | |
class ToRecord r => FromRecord (r :: Type) where Source #
Nothing
fromRecord :: Record I (RecordCode r) -> r Source #
fromRecord :: (Generic r, FromRecordHelper (RecordCode r) (Rep r)) => Record I (RecordCode r) -> r Source #
class FromRecordHelper (t :: RBT Symbol Type) (g :: Type -> Type) where Source #
fromRecord' :: Record I t -> g x Source #
Instances
(FromRecordHelper t t1, FromRecordHelper t t2) => FromRecordHelper t (t1 :*: t2) Source # | |
Defined in Data.RBR.Internal | |
(Key k t, Value k t ~ v) => FromRecordHelper t (S1 (MetaSel (Just k) unpackedness strictness laziness) (Rec0 v)) Source # | |
Defined in Data.RBR.Internal | |
FromRecordHelper t fields => FromRecordHelper t (D1 meta (C1 metacons fields)) Source # | |
Defined in Data.RBR.Internal |
type family VariantCode (s :: Type) :: RBT Symbol Type where ... Source #
VariantCode s = VariantCode' E (Rep s) |
type family VariantCode' (acc :: RBT Symbol Type) (g :: Type -> Type) :: RBT Symbol Type where ... Source #
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 #
Nothing
fromVariant :: Variant I (VariantCode s) -> s Source #
fromVariant :: (Generic s, FromVariantHelper (VariantCode s) (Rep s)) => Variant I (VariantCode s) -> s Source #
class FromVariantHelper (t :: RBT Symbol Type) (g :: Type -> Type) where Source #
Instances
(FromVariantHelper t t1, FromVariantHelper t t2) => FromVariantHelper t (t1 :+: t2) Source # | |
Defined in Data.RBR.Internal | |
(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 # | |
FromVariantHelper t fields => FromVariantHelper t (D1 meta fields) Source # | |
Defined in Data.RBR.Internal |
class ToVariant (s :: Type) where Source #
Nothing
toVariant :: s -> Variant I (VariantCode s) Source #
toVariant :: (Generic s, ToVariantHelper (VariantCode s) (Rep s)) => s -> Variant I (VariantCode s) Source #
class ToVariantHelper (t :: RBT Symbol Type) (g :: Type -> Type) where Source #
toVariant' :: g x -> Variant I t Source #
Instances
(ToVariantHelper t t1, ToVariantHelper t t2) => ToVariantHelper t (t1 :+: t2) Source # | |
Defined in Data.RBR.Internal | |
(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 # | |
ToVariantHelper t fields => ToVariantHelper t (D1 meta fields) Source # | |
Defined in Data.RBR.Internal |