Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides extensible Record
and Variant
types, which are
indexed by a type-level Map
.
Many functions in this module require the use of TypeApplications
to
avoid ambiguity. The order of the applications is the order of the type
variables in the function signature's forall
. The first type variable is
usually the field/branch name and it's always required. The other type
variables can often be inferred.
Meaning of commonly used type and kind variables:
t
: A type-levelMap
, usually of kindMap Symbol q
.k
: A key of kindSymbol
in a type-levelMap
.v
: A type value of kindq
in a type-levelMap
.q
: The kind of the type valuev
.f
: A type constructor of kindq -> Type
that wraps the typev
.flat
: A type-level list of kind[q]
whose elements correspond to values in a type-levelMap
.
See the Data.RBR.Examples module for examples of usage and links to external resources.
Synopsis
- data Map symbol q
- type Empty = E
- class KeysValuesAllF c t => KeysValuesAll (c :: symbol -> q -> Constraint) (t :: Map symbol q)
- class KnownSymbol k => KnownKey (k :: Symbol) (v :: q)
- demoteKeys :: forall t. KeysValuesAll KnownKey t => Record (K String) t
- class (KnownSymbol k, Typeable v) => KnownKeyTypeableValue (k :: Symbol) (v :: q)
- demoteEntries :: forall t. KeysValuesAll KnownKeyTypeableValue t => Record (K (String, TypeRep)) t
- class (kc k, vc v) => KeyValueConstraints (kc :: Symbol -> Constraint) (vc :: q -> Constraint) (k :: Symbol) (v :: q)
- class vc v => ValueConstraint (vc :: q -> Constraint) (k :: Symbol) (v :: q)
- class (Key k t, Value k t ~ v) => PresentIn (t :: Map Symbol q) (k :: Symbol) (v :: q)
- data Record (f :: q -> Type) (t :: Map Symbol q)
- unit :: Record f Empty
- data Variant (f :: q -> Type) (t :: Map Symbol q)
- impossible :: Variant f Empty -> b
- class Insertable (k :: Symbol) (v :: q) (t :: Map Symbol q) where
- type family InsertAll (es :: [(Symbol, q)]) (t :: Map Symbol q) :: Map Symbol q where ...
- type FromList (es :: [(Symbol, q)]) = InsertAll es Empty
- insert :: forall k v t f. Insertable k v t => f v -> Record f t -> Record f (Insert k v t)
- 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)
- widen :: forall k v t f. Insertable k v t => Variant f t -> Variant f (Insert k v t)
- class Deletable (k :: Symbol) (v :: q) (t :: Map Symbol q) where
- delete :: forall k v t f. Deletable k v t => Record f t -> Record f (Delete k v t)
- winnow :: forall k v t f. Deletable k v t => Variant f t -> Either (Variant f (Delete k v t)) (f v)
- winnowI :: forall k v t. Deletable k v t => Variant I t -> Either (Variant I (Delete k v t)) v
- class Key (k :: Symbol) (t :: Map Symbol q) where
- type Value k t :: q
- type family Field (f :: q -> Type) (t :: Map Symbol q) (v :: q) where ...
- field :: forall k t f. Key k t => Field f t (Value k t)
- type family Branch (f :: q -> Type) (t :: Map Symbol q) (v :: q) where ...
- branch :: forall k t f. Key k t => Branch f t (Value k t)
- project :: forall k t f. Key k t => Record f t -> f (Value k t)
- projectI :: forall k t. Key k t => Record I t -> Value k t
- getField :: forall k t f. Key k t => Record f t -> f (Value k t)
- getFieldI :: forall k t. Key k t => Record I t -> Value k t
- setField :: forall k t f. Key k t => f (Value k t) -> Record f t -> Record f t
- setFieldI :: forall k t. Key k t => Value k t -> Record I t -> Record I t
- modifyField :: forall k t f. Key k t => (f (Value k t) -> f (Value k t)) -> Record f t -> Record f t
- modifyFieldI :: forall k t. Key k t => (Value k t -> Value k t) -> Record I t -> Record I t
- inject :: forall k t f. Key k t => f (Value k t) -> Variant f t
- injectI :: forall k t. Key k t => Value k t -> Variant I t
- match :: forall k t f. Key k t => Variant f t -> Maybe (f (Value k t))
- matchI :: forall k t. Key k t => Variant I t -> Maybe (Value k t)
- class Maplike (t :: Map Symbol Type) where
- pure_Record :: (forall v. f v) -> Record f t
- sequence_Record :: Applicative f => Record f t -> f (Record I t)
- sequence'_Record :: Applicative f => Record (f :.: g) t -> f (Record g t)
- liftA_Record :: (forall a. f a -> g a) -> Record f t -> Record g t
- liftA2_Record :: (forall a. f a -> g a -> h a) -> Record f t -> Record g t -> Record h t
- liftA_Variant :: (forall a. f a -> g a) -> Variant f t -> Variant g t
- liftA2_Variant :: (forall a. f a -> g a -> h a) -> Record f t -> Variant g t -> Variant h t
- injections'_Variant :: Record (Case f (Variant f t)) t
- injections_Record :: Record (Case f (Endo (Record f t))) t
- collapse'_Record :: Monoid a => Record (K a) t -> a
- collapse_Variant :: Variant (K a) t -> a
- cpure_Record :: forall c t f. KeysValuesAll c t => Proxy c -> (forall k v. c k v => f v) -> Record f t
- cpure'_Record :: forall c t f. KeysValuesAll (KeyValueConstraints KnownSymbol c) t => Proxy c -> (forall v. c v => String -> f v) -> Record f t
- prettyShow_Record :: forall t f. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => (forall x. Show x => f x -> String) -> Record f t -> String
- prettyShow_RecordI :: forall t. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => Record I t -> String
- prettyShow_Variant :: forall t flat f. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => (forall x. Show x => f x -> String) -> Variant f t -> String
- prettyShow_VariantI :: forall t flat. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => Variant I t -> String
- eliminate_Variant :: Maplike t => Record (Case f r) t -> Variant f t -> r
- newtype Case f a b = Case {
- runCase :: 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)
- class ToRecord (r :: Type) where
- type RecordCode r :: Map Symbol Type
- toRecord :: r -> Record I (RecordCode r)
- class ToRecord r => FromRecord (r :: Type) where
- fromRecord :: Record I (RecordCode r) -> r
- type IsRecordType (r :: Type) (t :: Map Symbol Type) = (Generic r, ToRecord r, RecordCode r ~ t, FromRecord r)
- type family VariantCode (s :: Type) :: Map Symbol Type where ...
- class ToVariant (s :: Type) where
- toVariant :: s -> Variant I (VariantCode s)
- class FromVariant (s :: Type) where
- fromVariant :: Variant I (VariantCode s) -> s
- type IsVariantType (v :: Type) (t :: Map Symbol Type) = (Generic v, ToVariant v, VariantCode v ~ t, FromVariant v)
- class Productlike (start :: [k]) (t :: Map Symbol k) (result :: [k]) | start t -> result, result t -> start where
- prefixNP :: forall start t result f. Productlike start t result => Record f t -> NP f start -> NP f result
- breakNP :: forall start t result f. Productlike start t result => NP f result -> (Record f t, NP f start)
- 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 :: [k]) (t :: Map Symbol k) (result :: [k]) | start t -> result, result t -> start where
- prefixNS :: forall start t result f. Sumlike start t result => Either (NS f start) (Variant f t) -> NS f result
- breakNS :: forall start t result f. Sumlike start t result => NS f result -> Either (NS f start) (Variant f t)
- 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
- newtype I a = I a
- unI :: I a -> a
- newtype K a (b :: k) :: forall k. Type -> k -> Type = K a
- unK :: K a b -> a
- data NP (a :: k -> Type) (b :: [k]) :: forall k. (k -> Type) -> [k] -> Type where
- data NS (a :: k -> Type) (b :: [k]) :: forall k. (k -> Type) -> [k] -> Type where
- newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) :: forall l k. (l -> Type) -> (k -> l) -> k -> Type = Comp (f (g p))
- class (f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k)
- class Top (x :: k)
- collapse_Record :: forall t result a. Productlike '[] t result => Record (K a) t -> [a]
- injections_Variant :: Maplike t => Record (VariantInjection f t) t
- newtype VariantInjection (f :: q -> Type) (t :: Map Symbol q) (v :: q) = VariantInjection {
- runVariantInjection :: f v -> Variant f t
- eliminate :: (Productlike '[] t result, Sumlike '[] t result, SListI result) => Record (Case f r) t -> Variant f t -> r
- 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
- 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 ProductlikeSubset (subset :: Map Symbol q) (whole :: Map Symbol q) (flat :: [q]) = (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 :: Map Symbol q) (whole :: Map Symbol q) (subflat :: [q]) (wholeflat :: [q]) = (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
Type-level map
A type-level map that keeps track of which keys are present, and to which types they correspond.
Implemented as a red-black tree, and used as a kind by means of DataKinds
.
class KeysValuesAllF c t => KeysValuesAll (c :: symbol -> q -> Constraint) (t :: Map symbol q) Source #
Require a constraint for every key-value pair in a tree. This is a generalization of All
from Data.SOP.
Instances
KeysValuesAll (c :: symbol -> q -> Constraint) (E :: Map symbol q) Source # | |
Defined in Data.RBR.Internal | |
(c k v, KeysValuesAll c left, KeysValuesAll c right) => KeysValuesAll (c :: symbol -> q -> Constraint) (N color left k v right :: Map symbol q) Source # | |
Defined in Data.RBR.Internal |
class KnownSymbol k => KnownKey (k :: Symbol) (v :: q) Source #
Two-place constraint saying that a Symbol
key can be demoted to String
. Nothing is required from the corresponding value.
Defined using the "class synonym" trick.
Instances
KnownSymbol k => KnownKey k (v :: q) Source # | |
Defined in Data.RBR.Internal |
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.
>>>
putStrLn $ prettyShow_Record show $ demoteKeys @(FromList [ '("foo",Char), '("bar",Bool) ])
{bar = K "bar", foo = K "foo"}
For computations involving field names, sometimes cpure'_Record
is a better option.
class (KnownSymbol k, Typeable v) => KnownKeyTypeableValue (k :: Symbol) (v :: q) Source #
Two-place constraint saying that a Symbol
key can be demoted to String
, and that the corresponding value Type
has a term-level representation.
Defined using the "class synonym" trick.
Instances
(KnownSymbol k, Typeable v) => KnownKeyTypeableValue k (v :: q) Source # | |
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.
>>>
putStrLn $ prettyShow_Record show $ demoteEntries @(FromList [ '("foo",Char), '("bar",Bool) ])
{bar = K ("bar",Bool), foo = K ("foo",Char)}
class (kc k, vc v) => KeyValueConstraints (kc :: Symbol -> Constraint) (vc :: q -> Constraint) (k :: Symbol) (v :: q) Source #
Lifts two one-place constraints (one for keys, one for values) to a two-place constraint. Useful with function like cpure_Record
.
Defined using the "class synonym" trick.
Instances
(kc k, vc v) => KeyValueConstraints kc (vc :: q -> Constraint) k (v :: q) Source # | |
Defined in Data.RBR.Internal |
class vc v => ValueConstraint (vc :: q -> Constraint) (k :: Symbol) (v :: q) Source #
Lifts a one-place constraint for values to a two-place constraint. Useful with function like cpure_Record
.
Defined using the "class synonym" trick.
Instances
vc v => ValueConstraint (vc :: q -> Constraint) k (v :: q) Source # | |
Defined in Data.RBR.Internal |
class (Key k t, Value k t ~ v) => PresentIn (t :: Map Symbol q) (k :: Symbol) (v :: q) Source #
Records and Variants
data Record (f :: q -> Type) (t :: Map Symbol q) Source #
An extensible product-like type with named fields.
The values in the Record
come wrapped in a type constructor f
, which
for pure records will be the identity functor I
.
Instances
(Productlike ([] :: [q]) t result, Show (NP f result)) => Show (Record f t) Source # | |
FromRecord (Record I t) Source # | |
Defined in Data.RBR.Internal fromRecord :: Record I (RecordCode (Record I t)) -> Record I t Source # | |
ToRecord (Record I t) Source # | |
type RecordCode (Record I t) Source # | |
Defined in Data.RBR.Internal |
unit :: Record f Empty Source #
A Record without components is a boring, uninformative type whose single value can be conjured out of thin air.
impossible :: Variant f Empty -> b Source #
A Variant without branches doesn't have any values. From an impossible thing, anything can come out.
Inserting and widening
class Insertable (k :: Symbol) (v :: q) (t :: Map Symbol q) Source #
Class that determines if the pair of a Symbol
key and a type can
be inserted into a type-level map.
The associated type family Insert
produces the resulting map.
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 map already has the key but with a different type, the insertion fails to compile.
Instances
(InsertableHelper1 k v t, Insert1 k v t ~ inserted, CanMakeBlack inserted) => Insertable k (v :: q) (t :: Map Symbol q) Source # | |
type family InsertAll (es :: [(Symbol, q)]) (t :: Map Symbol q) :: Map Symbol q where ... Source #
Insert a list of type level key / value pairs into a type-level map.
type FromList (es :: [(Symbol, q)]) = InsertAll es Empty Source #
Build a type-level map out of a list of type level key / value pairs.
insert :: forall k v t f. Insertable k v t => f v -> Record f t -> Record f (Insert k v t) Source #
Adds a new field to a Record
.
>>>
project @"foo" (insert @"foo" (I 'a') unit)
I 'a'
>>>
project @"foo" (insert @"foo" @Char Nothing unit)
Nothing
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
.
widen :: forall k v t f. Insertable k v t => Variant f t -> Variant f (Insert k v t) Source #
Lets you use a Variant
in a bigger context
than the one in which is was defined.
Deleting and winnowing
class Deletable (k :: Symbol) (v :: q) (t :: Map Symbol q) Source #
Class that determines if the pair of a Symbol
key and a type can
be deleted from a type-level map.
The associated type family Delete
produces the resulting map.
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 map already has the key but with a different type, the deletion fails to compile.
delete :: forall k v t f. Deletable k v t => Record f t -> Record f (Delete k v t) Source #
Removes a field from a Record
.
winnow :: forall k v t f. Deletable k v t => 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 Variant
s.
>>>
winnow @"bar" @Bool (injectI @"bar" False :: Variant I (FromList [ '("foo",Char), '("bar",Bool) ]))
Right (I False)
>>>
prettyShow_VariantI `first` winnow @"foo" @Char (injectI @"bar" False :: Variant I (FromList [ '("foo",Char), '("bar",Bool) ]))
Left "bar (False)"
Projecting and injecting
class Key (k :: Symbol) (t :: Map Symbol q) Source #
Class that determines if a given Symbol
key is present in a type-level
map.
The Value
type family gives the Type
corresponding to the key.
type family Field (f :: q -> Type) (t :: Map Symbol q) (v :: q) where ... Source #
Auxiliary type family to avoid repetition and help improve compilation times.
field :: forall k t f. Key k t => Field f t (Value k t) Source #
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.
type family Branch (f :: q -> Type) (t :: Map Symbol q) (v :: q) where ... Source #
Auxiliary type family to avoid repetition and help improve compilation times.
branch :: forall k t f. Key k t => Branch f t (Value k t) Source #
Takes a branch name (given through TypeApplications
) and
returns a pair of a match function and a constructor.
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
.
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.
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 @"foo" (inject @"foo" (I 'a') :: Variant I (Insert "foo" Char Empty))
Just (I 'a')
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.
matchI :: forall k t. Key k t => Variant I t -> Maybe (Value k t) Source #
Like match
but specialized to pure Variants
s.
Transformations
class Maplike (t :: Map Symbol Type) where Source #
This typeclass provides generalizations of Applicative
-like functions
which work over Record
s and Variant
s.
pure_Record :: (forall v. f v) -> Record f t Source #
See cpure_Record
and cpure'_Record
for more useful versions of
this function.
The naming scheme follows that of pure_NP
.
sequence_Record :: Applicative f => Record f t -> f (Record I t) Source #
Pulls out an Applicative
that wraps each field, resulting in an Applicative
containing a pure Record
.
The naming scheme follows that of sequence_NP
.
sequence'_Record :: Applicative f => Record (f :.: g) t -> f (Record g t) Source #
Like sequence_Record
, but only pulls out the outer Applicative
from an Applicative
composition that wraps each field. See
:.:
.
This can be useful for staged computations, where each stage is
represented by an Applicative
layer.
The naming scheme follows that of sequence'_NP
.
liftA_Record :: (forall a. f a -> g a) -> Record f t -> Record g t Source #
Apply a transformation to the type constructor which wraps the fields of a Record
.
The naming scheme follows that of liftA_NP
.
liftA2_Record :: (forall a. f a -> g a -> h a) -> Record f t -> Record g t -> Record h t Source #
The naming scheme follows that of liftA2_NP
.
liftA_Variant :: (forall a. f a -> g a) -> Variant f t -> Variant g t Source #
Apply a transformation to the active branch of a Variant
.
The naming scheme follows that of liftA_NS
.
liftA2_Variant :: (forall a. f a -> g a -> h a) -> Record f t -> Variant g t -> Variant h t Source #
Given a Record
of transformation, apply the one which matches the active branch of Variant
.
The naming scheme follows that of liftA2_NS
.
injections'_Variant :: Record (Case f (Variant f t)) t Source #
Constructs a Record
made of functions which take a value of the
field's type and inject it in the Variant
branch which corresponds
to the field.
Compare to injections
from generics-sop
.
injections_Record :: Record (Case f (Endo (Record f t))) t Source #
Constructs a Record
made of functions which take a value of the
field's type and return a record updater function that sets the field.
collapse'_Record :: Monoid a => Record (K a) t -> a Source #
Collapse a Record
composed of K
monoidal annotations.
>>>
collapse'_Record (unit :: Record (K [Bool]) Empty)
[]
>>>
collapse'_Record (insert @"bar" (K [False]) unit)
[False]
The naming scheme follows that of collapse_NP
.
collapse_Variant :: Variant (K a) t -> a Source #
Instances
Maplike (E :: Map Symbol Type) Source # | |
Defined in Data.RBR.Internal pure_Record :: (forall v. f v) -> Record f E Source # sequence_Record :: Applicative f => Record f E -> f (Record I E) Source # sequence'_Record :: Applicative f => Record (f :.: g) E -> f (Record g E) Source # liftA_Record :: (forall a. f a -> g a) -> Record f E -> Record g E Source # liftA2_Record :: (forall a. f a -> g a -> h a) -> Record f E -> Record g E -> Record h E Source # liftA_Variant :: (forall a. f a -> g a) -> Variant f E -> Variant g E Source # liftA2_Variant :: (forall a. f a -> g a -> h a) -> Record f E -> Variant g E -> Variant h E Source # injections'_Variant :: Record (Case f (Variant f E)) E Source # injections_Record :: Record (Case f (Endo (Record f E))) E Source # collapse'_Record :: Monoid a => Record (K a) E -> a Source # | |
(Maplike left, Maplike right) => Maplike (N color left k v right) Source # | |
Defined in Data.RBR.Internal pure_Record :: (forall v0. f v0) -> Record f (N color left k v right) Source # sequence_Record :: Applicative f => Record f (N color left k v right) -> f (Record I (N color left k v right)) Source # sequence'_Record :: Applicative f => Record (f :.: g) (N color left k v right) -> f (Record g (N color left k v right)) Source # liftA_Record :: (forall a. f a -> g a) -> Record f (N color left k v right) -> Record g (N color left k v right) Source # liftA2_Record :: (forall a. f a -> g a -> h a) -> Record f (N color left k v right) -> Record g (N color left k v right) -> Record h (N color left k v right) Source # liftA_Variant :: (forall a. f a -> g a) -> Variant f (N color left k v right) -> Variant g (N color left k v right) Source # liftA2_Variant :: (forall a. f a -> g a -> h a) -> Record f (N color left k v right) -> Variant g (N color left k v right) -> Variant h (N color left k v right) Source # injections'_Variant :: Record (Case f (Variant f (N color left k v right))) (N color left k v right) Source # injections_Record :: Record (Case f (Endo (Record f (N color left k v right)))) (N color left k v right) Source # collapse'_Record :: Monoid a => Record (K a) (N color left k v right) -> a Source # collapse_Variant :: Variant (K a) (N color left k v right) -> a Source # |
cpure_Record :: forall c t f. KeysValuesAll c t => Proxy c -> (forall k v. c k v => f v) -> Record f t Source #
cpure'_Record :: forall c t f. KeysValuesAll (KeyValueConstraints KnownSymbol c) t => Proxy c -> (forall v. c v => String -> f v) -> Record f t Source #
prettyShow_Record :: forall t f. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => (forall x. Show x => f x -> String) -> Record f t -> String Source #
prettyShow_RecordI :: forall t. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => Record I t -> String Source #
Like prettyShow_Record
but specialized to pure records.
prettyShow_Variant :: forall t flat f. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => (forall x. Show x => f x -> String) -> Variant f t -> String Source #
prettyShow_VariantI :: forall t flat. (Maplike t, KeysValuesAll (KeyValueConstraints KnownSymbol Show) t) => Variant I t -> String Source #
Like prettyShow_Variant
but specialized to pure variants.
Eliminating variants
Represents a handler for a branch of a Variant
.
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
.
Interfacing with normal records
Typeclasses for converting to and from normal Haskell records and sum types.
They have default implementations based in GHC.Generics:
>>>
data Person = Person { name :: String, age :: Int } deriving (Generic, Show)
>>>
instance ToRecord Person
>>>
instance FromRecord Person
>>>
data Summy = Lefty Int | Righty Bool deriving (Generic,Show)
>>>
instance ToVariant Summy
>>>
instance FromVariant Summy
Only single-constructor records with named fields can have ToRecord
and
FromRecord
instances.
Only sum types with exactly one anonymous argument on each branch can have
ToVariant
and FromVariant
instances.
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 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 #
Instances
FromRecord (Record I t) Source # | |
Defined in Data.RBR.Internal fromRecord :: Record I (RecordCode (Record I t)) -> Record I t Source # |
type IsRecordType (r :: Type) (t :: Map Symbol Type) = (Generic r, ToRecord r, RecordCode r ~ t, FromRecord r) Source #
The naming scheme follows that of IsProductType
.
type family VariantCode (s :: Type) :: Map Symbol Type where ... Source #
VariantCode s = VariantCode' E (Rep s) |
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 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 #
type IsVariantType (v :: Type) (t :: Map Symbol Type) = (Generic v, ToVariant v, VariantCode v ~ t, FromVariant v) Source #
The naming scheme follows that of IsProductType
.
Interfacing with Data.SOP
class Productlike (start :: [k]) (t :: Map Symbol k) (result :: [k]) | 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.
_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 :: [k]) (E :: Map Symbol k) (start :: [k]) Source # | |
(Productlike start right middle, Productlike (v ': middle) left result) => Productlike (start :: [q]) (N color left k v right :: Map Symbol q) (result :: [q]) Source # | |
prefixNP :: forall start t result f. Productlike start t result => Record f t -> NP f start -> NP f result Source #
Flattens a Record
and adds it to the initial part of the product.
breakNP :: forall start t result f. Productlike start t result => NP f result -> (Record f t, NP f start) Source #
Reconstructs a Record
from the initial part of the product and returns the unconsumed part.
toNP :: forall t result f. Productlike '[] t result => Record f t -> NP f result Source #
Convert a Record
into a n-ary product. The order of the elements in the
product is not the order of insertion in the record.
>>>
toNP (insertI @"foo" 'a' (insertI @"bar" True unit))
I True :* I 'a' :* Nil
class Sumlike (start :: [k]) (t :: Map Symbol k) (result :: [k]) | 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 :: [q]) (N color (N colorL leftL kL vL rightL) k v (E :: Map Symbol q) :: Map Symbol q) (result :: [q]) Source # | |
(Sumlike start (N colorR leftR kR vR rightR) middle, Sumlike (v ': middle) (N colorL leftL kL vL rightL) result) => Sumlike (start :: [q]) (N color (N colorL leftL kL vL rightL) k v (N colorR leftR kR vR rightR) :: Map Symbol q) (result :: [q]) Source # | |
Defined in Data.RBR.Internal | |
Sumlike start (N colorR leftR kR vR rightR) middle => Sumlike (start :: [a]) (N color (E :: Map Symbol a) k v (N colorR leftR kR vR rightR) :: Map Symbol a) (v ': middle :: [a]) Source # | |
Sumlike (start :: [a]) (N color (E :: Map Symbol a) k v (E :: Map Symbol a) :: Map Symbol a) (v ': start :: [a]) Source # | |
prefixNS :: forall start t result f. Sumlike start t result => Either (NS f start) (Variant f t) -> NS f result Source #
Flattens a Variant
and adds it to the initial part of the sum.
breakNS :: forall start t result f. Sumlike start t result => NS f result -> Either (NS f start) (Variant f t) Source #
Reconstructs a Variant
from the initial part of the sum and returns the unconsumed part.
toNS :: forall t result f. Sumlike '[] t result => Variant f t -> NS f result Source #
Convert a Variant
into a n-ary sum.
>>>
toNS (injectI @"foo" 'a' :: Variant I (Insert "foo" Char (Insert "bar" Bool Empty)))
S (Z (I 'a'))
fromNS :: forall t result f. Sumlike '[] t result => NS f result -> Variant f t Source #
Convert a n-ary sum into a compatible Variant
.
>>>
:{
prettyShow_VariantI $ fromNS @(FromList [ '("foo",_), '("bar",_) ]) $ toNS $ (injectI @"foo" 'a' :: Variant I (FromList [ '("foo",Char), '("bar",Bool) ])) :} "foo ('a')"
Data.SOP re-exports
The identity type functor.
Like Identity
, but with a shorter name.
I a |
Instances
Monad I | |
Functor I | |
Applicative I | |
Foldable I | |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => I m -> m # foldMap :: Monoid m => (a -> m) -> I a -> m # foldr :: (a -> b -> b) -> b -> I a -> b # foldr' :: (a -> b -> b) -> b -> I a -> b # foldl :: (b -> a -> b) -> b -> I a -> b # foldl' :: (b -> a -> b) -> b -> I a -> b # foldr1 :: (a -> a -> a) -> I a -> a # foldl1 :: (a -> a -> a) -> I a -> a # elem :: Eq a => a -> I a -> Bool # maximum :: Ord a => I a -> a # | |
Traversable I | |
Eq1 I | Since: sop-core-0.2.4.0 |
Ord1 I | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read1 I | Since: sop-core-0.2.4.0 |
Show1 I | Since: sop-core-0.2.4.0 |
NFData1 I | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (I a) | |
Ord a => Ord (I a) | |
Read a => Read (I a) | |
Show a => Show (I a) | |
Generic (I a) | |
Semigroup a => Semigroup (I a) | Since: sop-core-0.4.0.0 |
Monoid a => Monoid (I a) | Since: sop-core-0.4.0.0 |
NFData a => NFData (I a) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
FromRecord (Record I t) Source # | |
Defined in Data.RBR.Internal fromRecord :: Record I (RecordCode (Record I t)) -> Record I t Source # | |
ToRecord (Record I t) Source # | |
type Rep (I a) | |
Defined in Data.SOP.BasicFunctors | |
type RecordCode (Record I t) Source # | |
Defined in Data.RBR.Internal |
newtype K a (b :: k) :: forall k. Type -> k -> Type #
The constant type functor.
Like Constant
, but kind-polymorphic
in its second argument and with a shorter name.
K a |
Instances
Eq2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Ord2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (K a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [K a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (K a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [K a b] # | |
Show2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
NFData2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Functor (K a :: Type -> Type) | |
Monoid a => Applicative (K a :: Type -> Type) | |
Foldable (K a :: Type -> Type) | |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => K a m -> m # foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m # foldr :: (a0 -> b -> b) -> b -> K a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b # foldl :: (b -> a0 -> b) -> b -> K a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # elem :: Eq a0 => a0 -> K a a0 -> Bool # maximum :: Ord a0 => K a a0 -> a0 # minimum :: Ord a0 => K a a0 -> a0 # | |
Traversable (K a :: Type -> Type) | |
Eq a => Eq1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Ord a => Ord1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read a => Read1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Show a => Show1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
NFData a => NFData1 (K a :: Type -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (K a b) | |
Ord a => Ord (K a b) | |
Read a => Read (K a b) | |
Show a => Show (K a b) | |
Generic (K a b) | |
Semigroup a => Semigroup (K a b) | Since: sop-core-0.4.0.0 |
Monoid a => Monoid (K a b) | Since: sop-core-0.4.0.0 |
NFData a => NFData (K a b) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
type Rep (K a b) | |
Defined in Data.SOP.BasicFunctors |
data NP (a :: k -> Type) (b :: [k]) :: forall k. (k -> Type) -> [k] -> Type where #
An n-ary product.
The product is parameterized by a type constructor f
and
indexed by a type-level list xs
. The length of the list
determines the number of elements in the product, and if the
i
-th element of the list is of type x
, then the i
-th
element of the product is of type f x
.
The constructor names are chosen to resemble the names of the list constructors.
Two common instantiations of f
are the identity functor I
and the constant functor K
. For I
, the product becomes a
heterogeneous list, where the type-level list describes the
types of its components. For
, the product becomes a
homogeneous list, where the contents of the type-level list are
ignored, but its length still specifies the number of elements.K
a
In the context of the SOP approach to generic programming, an n-ary product describes the structure of the arguments of a single data constructor.
Examples:
I 'x' :* I True :* Nil :: NP I '[ Char, Bool ] K 0 :* K 1 :* Nil :: NP (K Int) '[ Char, Bool ] Just 'x' :* Nothing :* Nil :: NP Maybe '[ Char, Bool ]
Nil :: forall k (a :: k -> Type) (b :: [k]). NP a ([] :: [k]) | |
(:*) :: forall k (a :: k -> Type) (b :: [k]) (x :: k) (xs :: [k]). a x -> NP a xs -> NP a (x ': xs) infixr 5 |
Instances
HTrans (NP :: (k1 -> Type) -> [k1] -> Type) (NP :: (k2 -> Type) -> [k2] -> Type) | |
HPure (NP :: (k -> Type) -> [k] -> Type) | |
HAp (NP :: (k -> Type) -> [k] -> Type) | |
HCollapse (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP | |
HTraverse_ (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP hctraverse_ :: (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g ()) -> NP f xs -> g () # htraverse_ :: (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g ()) -> NP f xs -> g () # | |
HSequence (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP hsequence' :: (SListIN NP xs, Applicative f) => NP (f :.: g) xs -> f (NP g xs) # hctraverse' :: (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g (f' a)) -> NP f xs -> g (NP f' xs) # htraverse' :: (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g (f' a)) -> NP f xs -> g (NP f' xs) # | |
All (Compose Eq f) xs => Eq (NP f xs) | |
(All (Compose Eq f) xs, All (Compose Ord f) xs) => Ord (NP f xs) | |
All (Compose Show f) xs => Show (NP f xs) | |
All (Compose Semigroup f) xs => Semigroup (NP f xs) | Since: sop-core-0.4.0.0 |
(All (Compose Monoid f) xs, All (Compose Semigroup f) xs) => Monoid (NP f xs) | Since: sop-core-0.4.0.0 |
All (Compose NFData f) xs => NFData (NP f xs) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.NP | |
type Same (NP :: (k1 -> Type) -> [k1] -> Type) | |
type Prod (NP :: (k -> Type) -> [k] -> Type) | |
type UnProd (NP :: (k -> Type) -> [k] -> Type) | |
type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a | |
Defined in Data.SOP.NP | |
type SListIN (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP | |
type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) | |
Defined in Data.SOP.NP | |
type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) | |
Defined in Data.SOP.NP |
data NS (a :: k -> Type) (b :: [k]) :: forall k. (k -> Type) -> [k] -> Type where #
An n-ary sum.
The sum is parameterized by a type constructor f
and
indexed by a type-level list xs
. The length of the list
determines the number of choices in the sum and if the
i
-th element of the list is of type x
, then the i
-th
choice of the sum is of type f x
.
The constructor names are chosen to resemble Peano-style
natural numbers, i.e., Z
is for "zero", and S
is for
"successor". Chaining S
and Z
chooses the corresponding
component of the sum.
Examples:
Z :: f x -> NS f (x ': xs) S . Z :: f y -> NS f (x ': y ': xs) S . S . Z :: f z -> NS f (x ': y ': z ': xs) ...
Note that empty sums (indexed by an empty list) have no non-bottom elements.
Two common instantiations of f
are the identity functor I
and the constant functor K
. For I
, the sum becomes a
direct generalization of the Either
type to arbitrarily many
choices. For
, the result is a homogeneous choice type,
where the contents of the type-level list are ignored, but its
length specifies the number of options.K
a
In the context of the SOP approach to generic programming, an n-ary sum describes the top-level structure of a datatype, which is a choice between all of its constructors.
Examples:
Z (I 'x') :: NS I '[ Char, Bool ] S (Z (I True)) :: NS I '[ Char, Bool ] S (Z (K 1)) :: NS (K Int) '[ Char, Bool ]
Z :: forall k (a :: k -> Type) (b :: [k]) (x :: k) (xs :: [k]). a x -> NS a (x ': xs) | |
S :: forall k (a :: k -> Type) (b :: [k]) (xs :: [k]) (x :: k). NS a xs -> NS a (x ': xs) |
Instances
HTrans (NS :: (k1 -> Type) -> [k1] -> Type) (NS :: (k2 -> Type) -> [k2] -> Type) | |
HAp (NS :: (k -> Type) -> [k] -> Type) | |
HCollapse (NS :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NS | |
HTraverse_ (NS :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NS hctraverse_ :: (AllN NS c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g ()) -> NS f xs -> g () # htraverse_ :: (SListIN NS xs, Applicative g) => (forall (a :: k0). f a -> g ()) -> NS f xs -> g () # | |
HSequence (NS :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NS hsequence' :: (SListIN NS xs, Applicative f) => NS (f :.: g) xs -> f (NS g xs) # hctraverse' :: (AllN NS c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g (f' a)) -> NS f xs -> g (NS f' xs) # htraverse' :: (SListIN NS xs, Applicative g) => (forall (a :: k0). f a -> g (f' a)) -> NS f xs -> g (NS f' xs) # | |
HIndex (NS :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NS | |
HApInjs (NS :: (k -> Type) -> [k] -> Type) | |
HExpand (NS :: (k -> Type) -> [k] -> Type) | |
All (Compose Eq f) xs => Eq (NS f xs) | |
(All (Compose Eq f) xs, All (Compose Ord f) xs) => Ord (NS f xs) | |
All (Compose Show f) xs => Show (NS f xs) | |
All (Compose NFData f) xs => NFData (NS f xs) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.NS | |
type Same (NS :: (k1 -> Type) -> [k1] -> Type) | |
type Prod (NS :: (k -> Type) -> [k] -> Type) | |
type CollapseTo (NS :: (k -> Type) -> [k] -> Type) a | |
Defined in Data.SOP.NS | |
type SListIN (NS :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NS | |
type AllN (NS :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) | |
Defined in Data.SOP.NS |
newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) :: forall l k. (l -> Type) -> (k -> l) -> k -> Type infixr 7 #
Composition of functors.
Like Compose
, but kind-polymorphic
and with a shorter name.
Comp (f (g p)) |
Instances
(Functor f, Functor g) => Functor (f :.: g) | |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: sop-core-0.2.5.0 |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # | |
(Traversable f, Traversable g) => Traversable (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Eq1 f, Eq1 g) => Eq1 (f :.: g) | Since: sop-core-0.2.4.0 |
(Ord1 f, Ord1 g) => Ord1 (f :.: g) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Read1 f, Read1 g) => Read1 (f :.: g) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Show1 f, Show1 g) => Show1 (f :.: g) | Since: sop-core-0.2.4.0 |
(NFData1 f, NFData1 g) => NFData1 (f :.: g) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Eq1 f, Eq1 g, Eq a) => Eq ((f :.: g) a) | |
(Ord1 f, Ord1 g, Ord a) => Ord ((f :.: g) a) | |
Defined in Data.SOP.BasicFunctors | |
(Read1 f, Read1 g, Read a) => Read ((f :.: g) a) | |
(Show1 f, Show1 g, Show a) => Show ((f :.: g) a) | |
Generic ((f :.: g) p) | |
Semigroup (f (g x)) => Semigroup ((f :.: g) x) | Since: sop-core-0.4.0.0 |
Monoid (f (g x)) => Monoid ((f :.: g) x) | Since: sop-core-0.4.0.0 |
NFData (f (g a)) => NFData ((f :.: g) a) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
type Rep ((f :.: g) p) | |
Defined in Data.SOP.BasicFunctors |
class (f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k) infixl 7 #
Pairing of constraints.
Since: sop-core-0.2
Instances
(f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k) | |
Defined in Data.SOP.Constraint |
A constraint that can always be satisfied.
Since: sop-core-0.2
Instances
Top (x :: k) | |
Defined in Data.SOP.Constraint |
Deprecated
collapse_Record :: forall t result a. Productlike '[] t result => Record (K a) t -> [a] Source #
Deprecated: Use collapse'_Record
injections_Variant :: Maplike t => Record (VariantInjection f t) t Source #
Deprecated: Use injections'_Variant instead
newtype VariantInjection (f :: q -> Type) (t :: Map Symbol q) (v :: q) Source #
Deprecated: Use Case instead
VariantInjection | Deprecated: Use Case instead |
|
eliminate :: (Productlike '[] t result, Sumlike '[] t result, SListI result) => Record (Case f r) t -> Variant f t -> r Source #
Deprecated: Use eliminate_Variant instead.
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 #
Deprecated: Use prettyShow_Record
prettyShowRecordI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, All Show flat, SListI flat) => Record I t -> String Source #
Deprecated: Use prettyShow_RecordI
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 #
Deprecated: Use prettyShow_Variant
prettyShowVariantI :: forall t flat. (KeysValuesAll KnownKey t, Productlike '[] t flat, Sumlike '[] t flat, All Show flat, SListI flat) => Variant I t -> String Source #
Deprecated: Use prettyShow_VariantI
type ProductlikeSubset (subset :: Map Symbol q) (whole :: Map Symbol q) (flat :: [q]) = (KeysValuesAll (PresentIn whole) subset, Productlike '[] subset flat, SListI flat) Source #
Deprecated: This constraint is obsolete
fieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> (Record f subset -> Record f whole, Record f subset) Source #
Deprecated: Use Data.RBR.Subset.fieldSubset
projectSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset Source #
Deprecated: Use Data.RBR.Subset.projectSubset
getFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f whole -> Record f subset Source #
Deprecated: Use Data.RBR.Subset.getFieldSubset
setFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => Record f subset -> Record f whole -> Record f whole Source #
Deprecated: Use Data.RBR.Subset.setFieldSubset
modifyFieldSubset :: forall subset whole flat f. ProductlikeSubset subset whole flat => (Record f subset -> Record f subset) -> Record f whole -> Record f whole Source #
Deprecated: Use Data.RBR.Subset.modifyFieldSubset
type SumlikeSubset (subset :: Map Symbol q) (whole :: Map Symbol q) (subflat :: [q]) (wholeflat :: [q]) = (KeysValuesAll (PresentIn whole) subset, Productlike '[] whole wholeflat, Sumlike '[] whole wholeflat, SListI wholeflat, Productlike '[] subset subflat, Sumlike '[] subset subflat, SListI subflat) Source #
Deprecated: This constraint is obsolete
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 #
Deprecated: Use Data.RBR.Subset.branchSubset
injectSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f subset -> Variant f whole Source #
Deprecated: Use Data.RBR.Subset.injectSubset
matchSubset :: forall subset whole subflat wholeflat f. SumlikeSubset subset whole subflat wholeflat => Variant f whole -> Maybe (Variant f subset) Source #
Deprecated: Use Data.RBR.Subset.matchSubset
eliminateSubset :: forall subset whole subflat wholeflat f r. SumlikeSubset subset whole subflat wholeflat => Record (Case f r) whole -> Variant f subset -> r Source #
Deprecated: Use Data.RBR.Subset.eliminateSubset