-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Open Records and Variants -- -- This package uses closed type families and type literals to implement -- open records and variants. The core is based off of the CTRex -- package, but it additionally includes polymorphic variants and a -- number of additional functions. That said, it is not a proper superset -- of CTRex as it specifically forbids records from having more than one -- element of the same label. @package row-types @version 0.3.1.0 -- | This module implements the internals of open records and variants. module Data.Row.Internal -- | The kind of rows. This type is only used as a datakind. A row is a -- typelevel entity telling us which symbols are associated with which -- types. newtype Row a -- | A row is a list of symbol-to-type pairs that should always be sorted -- lexically by the symbol. The constructor is exported here (because -- this is an internal module) but should not be exported elsewhere. R :: [LT a] -> Row a -- | A label data Label (s :: Symbol) Label :: Label -- | This class gives the string associated with a type-level symbol. There -- are instances of the class for every concrete literal: "hello", etc. class KnownSymbol (n :: Symbol) -- | The kind of elements of rows. Each element is a label and its -- associated type. data LT a (:->) :: Symbol -> a -> LT a -- | Type level version of empty type Empty = R '[] -- | Elements stored in a Row type are usually hidden. data HideType [HideType] :: a -> HideType -- | Type level Row extension type family Extend (l :: Symbol) (a :: k) (r :: Row k) :: Row k -- | Type level Row modification type family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k -- | Type level row renaming type family Rename (l :: Symbol) (l' :: Symbol) (r :: Row k) :: Row k -- | A type level way to create a singleton Row. type (l :: Symbol) .== (a :: k) = Extend l a Empty infix 7 .== -- | Type level label fetching type family (r :: Row k) .! (t :: Symbol) :: k infixl 5 .! -- | Type level Row element removal type family (r :: Row k) .- (s :: Symbol) :: Row k infixl 6 .- -- | Type level Row difference. That is, l .\\ r is the row -- remaining after removing any matching elements of r from -- l. type family (l :: Row k) .\\ (r :: Row k) :: Row k infixl 6 .\\ -- | Type level Row append type family (l :: Row k) .+ (r :: Row k) :: Row k infixl 6 .+ -- | The minimum join of the two rows. type family (l :: Row k) .\/ (r :: Row k) infixl 6 .\/ -- | The overwriting union, where the left row overwrites the types of the -- right row where the labels overlap. type family (l :: Row k) .// (r :: Row k) infixl 6 .// -- | Alias for .\. It is a class rather than an alias, so that it -- can be partially applied. class Lacks (l :: Symbol) (r :: Row *) -- | Does the row lack (i.e. it does not have) the specified label? type family (r :: Row k) .\ (l :: Symbol) :: Constraint infixl 4 .\ -- | Alias for (r .! l) ≈ a. It is a class rather than an alias, -- so that it can be partially applied. class (r .! l ≈ a) => HasType l a r -- | Any structure over a row in which every element is similarly -- constrained can be metamorphized into another structure over the same -- row. class Forall (r :: Row k) (c :: k -> Constraint) -- | A metamorphism is an unfold followed by a fold. This one is for -- product-like row-types (e.g. Rec). metamorph :: forall (f :: Row k -> *) (g :: Row k -> *) (h :: k -> *). Forall r c => Proxy h -> (f Empty -> g Empty) -> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> f ( 'R ((ℓ :-> τ) : ρ)) -> (h τ, f ( 'R ρ))) -> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> h τ -> g ( 'R ρ) -> g ( 'R ((ℓ :-> τ) : ρ))) -> f r -> g r -- | A metamorphism is an unfold followed by a fold. This one is for -- sum-like row-types (e.g. Var). metamorph' :: forall (f :: Row k -> *) (g :: Row k -> *) (h :: k -> *). Forall r c => Proxy h -> (f Empty -> g Empty) -> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> f ( 'R ((ℓ :-> τ) : ρ)) -> Either (h τ) (f ( 'R ρ))) -> (forall ℓ τ ρ. (KnownSymbol ℓ, c τ) => Label ℓ -> Either (h τ) (g ( 'R ρ)) -> g ( 'R ((ℓ :-> τ) : ρ))) -> f r -> g r -- | Any structure over two rows in which the elements of each row satisfy -- some constraints can be metamorphized into another structure over both -- of the rows. class BiForall (r1 :: Row k1) (r2 :: Row k2) (c :: k1 -> k2 -> Constraint) -- | A metamorphism is a fold followed by an unfold. This one is for -- product-like row-types. biMetamorph :: forall (f :: Row k1 -> Row k2 -> *) (g :: Row k1 -> Row k2 -> *) (h :: k1 -> k2 -> *). BiForall r1 r2 c => Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> f ( 'R ((ℓ :-> τ1) : ρ1)) ( 'R ((ℓ :-> τ2) : ρ2)) -> (h τ1 τ2, f ( 'R ρ1) ( 'R ρ2))) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> h τ1 τ2 -> g ( 'R ρ1) ( 'R ρ2) -> g ( 'R ((ℓ :-> τ1) : ρ1)) ( 'R ((ℓ :-> τ2) : ρ2))) -> f r1 r2 -> g r1 r2 -- | A metamorphism is a fold followed by an unfold. This one is for -- sum-like row-types. biMetamorph' :: forall (f :: Row k1 -> Row k2 -> *) (g :: Row k1 -> Row k2 -> *) (h :: k1 -> k2 -> *). BiForall r1 r2 c => Proxy h -> (f Empty Empty -> g Empty Empty) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> f ( 'R ((ℓ :-> τ1) : ρ1)) ( 'R ((ℓ :-> τ2) : ρ2)) -> Either (h τ1 τ2) (f ( 'R ρ1) ( 'R ρ2))) -> (forall ℓ τ1 τ2 ρ1 ρ2. (KnownSymbol ℓ, c τ1 τ2) => Label ℓ -> Either (h τ1 τ2) (g ( 'R ρ1) ( 'R ρ2)) -> g ( 'R ((ℓ :-> τ1) : ρ1)) ( 'R ((ℓ :-> τ2) : ρ2))) -> f r1 r2 -> g r1 r2 -- | A pair of constraints class (c1 x, c2 y) => BiConstraint c1 c2 x y -- | A null constraint of one argument class Unconstrained1 a -- | A null constraint of two arguments class Unconstrained2 a b -- | A convenient way to provide common, easy constraints type WellBehaved ρ = (Forall ρ Unconstrained1, AllUniqueLabels ρ) -- | Are all of the labels in this Row unique? type family AllUniqueLabels (r :: Row k) :: Constraint -- | Take two rows with the same labels, and apply the type operator from -- the first row to the type of the second. type family Ap (fs :: Row (a -> b)) (r :: Row a) :: Row b -- | Zips two rows together to create a Row of the pairs. The two rows must -- have the same set of labels. type family Zip (r1 :: Row *) (r2 :: Row *) -- | Map a type level function over a Row. type family Map (f :: a -> b) (r :: Row a) :: Row b -- | Is the first row a subset of the second? type family Subset (r1 :: Row k) (r2 :: Row k) :: Constraint -- | A type synonym for disjointness. type Disjoint l r = (WellBehaved l, WellBehaved r, Subset l (l .+ r), Subset r (l .+ r), l .+ r .\\ l ≈ r, l .+ r .\\ r ≈ l) -- | The labels in a Row. type family Labels (r :: Row a) -- | Return a list of the labels in a row type. labels :: forall ρ c s. (IsString s, Forall ρ c) => [s] -- | Return a list of the labels in a row type and is specialized to the -- Unconstrained1 constraint. labels' :: forall ρ s. (IsString s, Forall ρ Unconstrained1) => [s] -- | A helper function for showing labels show' :: (IsString s, Show a) => a -> s -- | A helper function to turn a Label directly into Text. toKey :: forall s. KnownSymbol s => Label s -> Text -- | A lower fixity operator for type equality type a ≈ b = a ~ b infix 4 ≈ -- | This allows us to derive a `Forall (Map f r) ..` from a `Forall r ..`. mapForall :: forall f c ρ. Forall ρ c :- Forall (Map f ρ) (IsA c f) -- | Allow any Forall over a row-type, be usable for -- Unconstrained1. freeForall :: forall r c. Forall r c :- Forall r Unconstrained1 -- | Map preserves uniqueness of labels. uniqueMap :: forall f ρ. AllUniqueLabels ρ :- AllUniqueLabels (Map f ρ) -- | This allows us to derive `Map f r .! l ≈ f t` from `r .! l ≈ t` mapHas :: forall f r l t. ((r .! l) ≈ t) :- ((Map f r .! l) ≈ f t) -- | A class to capture the idea of As so that it can be partially -- applied in a context. class IsA c f a as :: IsA c f a => As c f a -- | This data type is used to for its ability to existentially bind a type -- variable. Particularly, it says that for the type a, there -- exists a t such that 'a ~ f t' and 'c t' holds. data As c f a [As] :: forall c f a t. (a ~ f t, c t) => As c f a instance GHC.Classes.Eq (Data.Row.Internal.Label s) instance forall k (r :: Data.Row.Internal.Row k) (l :: GHC.Types.Symbol) (a :: k). ((r Data.Row.Internal..! l) Data.Row.Internal.≈ a) => Data.Row.Internal.HasType l a r instance (x Data.Row.Internal.≈ y) => GHC.OverloadedLabels.IsLabel x (Data.Row.Internal.Label y) instance (r Data.Row.Internal..\ l) => Data.Row.Internal.Lacks l r instance forall k1 k2 (c1 :: k2 -> GHC.Types.Constraint) (x :: k2) (c2 :: k1 -> GHC.Types.Constraint) (y :: k1). (c1 x, c2 y) => Data.Row.Internal.BiConstraint c1 c2 x y instance forall k1 k2 (a :: k2) (b :: k1). Data.Row.Internal.Unconstrained2 a b instance forall k (a :: k). Data.Row.Internal.Unconstrained1 a instance Data.Row.Internal.Unconstrained instance forall k1 k2 (c1 :: k1 -> k2 -> GHC.Types.Constraint). Data.Row.Internal.BiForall ('Data.Row.Internal.R '[]) ('Data.Row.Internal.R '[]) c1 instance forall k1 k2 (ℓ :: GHC.Types.Symbol) (c :: k1 -> k2 -> GHC.Types.Constraint) (τ1 :: k1) (τ2 :: k2) (ρ1 :: [Data.Row.Internal.LT k1]) (ρ2 :: [Data.Row.Internal.LT k2]). (GHC.TypeLits.KnownSymbol ℓ, c τ1 τ2, Data.Row.Internal.BiForall ('Data.Row.Internal.R ρ1) ('Data.Row.Internal.R ρ2) c) => Data.Row.Internal.BiForall ('Data.Row.Internal.R ((ℓ 'Data.Row.Internal.:-> τ1) : ρ1)) ('Data.Row.Internal.R ((ℓ 'Data.Row.Internal.:-> τ2) : ρ2)) c instance forall k1 k2 (c :: k2 -> GHC.Types.Constraint) (a :: k2) (f :: k2 -> k1). c a => Data.Row.Internal.IsA c f (f a) instance forall k (c :: k -> GHC.Types.Constraint). Data.Row.Internal.Forall ('Data.Row.Internal.R '[]) c instance forall k (ℓ :: GHC.Types.Symbol) (c :: k -> GHC.Types.Constraint) (τ :: k) (ρ :: [Data.Row.Internal.LT k]). (GHC.TypeLits.KnownSymbol ℓ, c τ, Data.Row.Internal.Forall ('Data.Row.Internal.R ρ) c) => Data.Row.Internal.Forall ('Data.Row.Internal.R ((ℓ 'Data.Row.Internal.:-> τ) : ρ)) c instance GHC.TypeLits.KnownSymbol s => GHC.Show.Show (Data.Row.Internal.Label s) -- | This module implements extensible records using closed type famillies. -- -- See Examples.lhs for examples. -- -- Lists of (label,type) pairs are kept sorted thereby ensuring that { x -- = 0, y = 0 } and { y = 0, x = 0 } have the same type. -- -- In this way we can implement standard type classes such as Show, Eq, -- Ord and Bounded for open records, given that all the elements of the -- open record satify the constraint. module Data.Row.Records -- | A label data Label (s :: Symbol) Label :: Label -- | This class gives the string associated with a type-level symbol. There -- are instances of the class for every concrete literal: "hello", etc. class KnownSymbol (n :: Symbol) -- | Are all of the labels in this Row unique? type family AllUniqueLabels (r :: Row k) :: Constraint -- | A convenient way to provide common, easy constraints type WellBehaved ρ = (Forall ρ Unconstrained1, AllUniqueLabels ρ) -- | A record with row r. data Rec (r :: Row *) -- | The kind of rows. This type is only used as a datakind. A row is a -- typelevel entity telling us which symbols are associated with which -- types. data Row a -- | Type level version of empty type Empty = R '[] -- | A lower fixity operator for type equality type a ≈ b = a ~ b infix 4 ≈ -- | The empty record empty :: Rec Empty -- | A type level way to create a singleton Row. type (l :: Symbol) .== (a :: k) = Extend l a Empty infix 7 .== -- | The singleton record (.==) :: KnownSymbol l => Label l -> a -> Rec (l .== a) infix 7 .== -- | A pattern for the singleton record; can be used to both destruct a -- record when in a pattern position or construct one in an expression -- position. pattern (:==) :: forall l a. KnownSymbol l => Label l -> a -> Rec (l .== a) infix 7 :== -- | Turns a singleton record into a pair of the label and value. unSingleton :: forall l a. KnownSymbol l => Rec (l .== a) -> (Label l, a) -- | Initialize a record with a default value at each label. default' :: forall c ρ. (Forall ρ c, AllUniqueLabels ρ) => (forall a. c a => a) -> Rec ρ -- | Initialize a record with a default value at each label; works over an -- Applicative. defaultA :: forall c f ρ. (Applicative f, Forall ρ c, AllUniqueLabels ρ) => (forall a. c a => f a) -> f (Rec ρ) -- | Initialize a record, where each value is determined by the given -- function over the label at that value. fromLabels :: forall c ρ. (Forall ρ c, AllUniqueLabels ρ) => (forall l a. (KnownSymbol l, c a) => Label l -> a) -> Rec ρ -- | Initialize a record, where each value is determined by the given -- function over the label at that value. This function works over an -- Applicative. fromLabelsA :: forall c f ρ. (Applicative f, Forall ρ c, AllUniqueLabels ρ) => (forall l a. (KnownSymbol l, c a) => Label l -> f a) -> f (Rec ρ) -- | Initialize a record that is produced by a Map. fromLabelsMapA :: forall c f g ρ. (Applicative f, Forall ρ c, AllUniqueLabels ρ) => (forall l a. (KnownSymbol l, c a) => Label l -> f (g a)) -> f (Rec (Map g ρ)) -- | Record extension. The row may already contain the label, in which case -- the origin value can be obtained after restriction (.-) with -- the label. extend :: forall a l r. KnownSymbol l => Label l -> a -> Rec r -> Rec (Extend l a r) -- | Type level Row extension type family Extend (l :: Symbol) (a :: k) (r :: Row k) :: Row k -- | Alias for .\. It is a class rather than an alias, so that it -- can be partially applied. class Lacks (l :: Symbol) (r :: Row *) -- | Does the row lack (i.e. it does not have) the specified label? type family (r :: Row k) .\ (l :: Symbol) :: Constraint infixl 4 .\ -- | Type level Row element removal type family (r :: Row k) .- (s :: Symbol) :: Row k infixl 6 .- -- | Record restriction. Remove the label l from the record. (.-) :: KnownSymbol l => Rec r -> Label l -> Rec (r .- l) infixl 6 .- -- | Arbitrary record restriction. Turn a record into a subset of itself. restrict :: forall r r'. (Forall r Unconstrained1, Subset r r') => Rec r' -> Rec r -- | Split a record into two sub-records. split :: forall s r. (Forall s Unconstrained1, Subset s r) => Rec r -> (Rec s, Rec (r .\\ s)) -- | Update the value associated with the label. update :: (KnownSymbol l, (r .! l) ≈ a) => Label l -> a -> Rec r -> Rec r -- | Focus on the value associated with the label. focus :: (KnownSymbol l, (r' .! l) ≈ b, (r .! l) ≈ a, r' ~ Modify l b r, r ~ Modify l a r', Functor f) => Label l -> (a -> f b) -> Rec r -> f (Rec r') -- | Focus on a sub-record multifocus :: forall u v r f. (Functor f, Disjoint u r, Disjoint v r) => (Rec u -> f (Rec v)) -> Rec (u .+ r) -> f (Rec (v .+ r)) -- | Type level Row modification type family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k -- | Rename a label. rename :: (KnownSymbol l, KnownSymbol l') => Label l -> Label l' -> Rec r -> Rec (Rename l l' r) -- | Type level row renaming type family Rename (l :: Symbol) (l' :: Symbol) (r :: Row k) :: Row k -- | Alias for (r .! l) ≈ a. It is a class rather than an alias, -- so that it can be partially applied. class (r .! l ≈ a) => HasType l a r -- | Type level label fetching type family (r :: Row k) .! (t :: Symbol) :: k infixl 5 .! -- | Record selection (.!) :: KnownSymbol l => Rec r -> Label l -> r .! l -- | Type level Row append type family (l :: Row k) .+ (r :: Row k) :: Row k infixl 6 .+ -- | Record disjoint union (commutative) (.+) :: Rec l -> Rec r -> Rec (l .+ r) infixl 6 .+ -- | A type synonym for disjointness. type Disjoint l r = (WellBehaved l, WellBehaved r, Subset l (l .+ r), Subset r (l .+ r), l .+ r .\\ l ≈ r, l .+ r .\\ r ≈ l) -- | A pattern version of record union, for use in pattern matching. pattern (:+) :: forall l r. Disjoint l r => Rec l -> Rec r -> Rec (l .+ r) infixl 6 :+ -- | The overwriting union, where the left row overwrites the types of the -- right row where the labels overlap. type family (l :: Row k) .// (r :: Row k) infixl 6 .// -- | Record overwrite. -- -- The operation r .// r' creates a new record such that: -- --
-- myShow :: Var ("y" '::= String :| "x" '::= Int :| Empty) -> String
-- myShow (view x -> Just n) = "Int of "++show n
-- myShow (view y -> Just s) = "String of "++s
--
view :: KnownSymbol l => Label l -> Var r -> Maybe (r .! l)
-- | Arbitrary variant restriction. Turn a variant into a subset of itself.
restrict :: forall r r'. (WellBehaved r, Subset r r') => Var r' -> Maybe (Var r)
-- | Split a variant into two sub-variants.
split :: forall s r. (WellBehaved s, Subset s r) => Var r -> Either (Var s) (Var (r .\\ s))
-- | Type level label fetching
type family (r :: Row k) .! (t :: Symbol) :: k
infixl 5 .!
-- | Type level Row element removal
type family (r :: Row k) .- (s :: Symbol) :: Row k
infixl 6 .-
-- | Type level Row difference. That is, l .\\ r is the row
-- remaining after removing any matching elements of r from
-- l.
type family (l :: Row k) .\\ (r :: Row k) :: Row k
infixl 6 .\\
-- | A type level way to create a singleton Row.
type (l :: Symbol) .== (a :: k) = Extend l a Empty
infix 7 .==
-- | Convert a variant to a native Haskell type.
toNative :: ToNative t ρ => Var ρ -> t
-- | Convert a Haskell record to a row-types Var.
fromNative :: FromNative t ρ => t -> Var ρ
-- | Convert a Haskell record to a row-types Var.
fromNativeExact :: FromNativeExact t ρ => t -> Var ρ
type ToNative t ρ = (Generic t, ToNativeG (Rep t) ρ)
type FromNative t ρ = (Generic t, FromNativeG (Rep t) ρ)
type FromNativeExact t ρ = (Generic t, FromNativeExactG (Rep t) ρ)
-- | Map a type level function over a Row.
type family Map (f :: a -> b) (r :: Row a) :: Row b
-- | A function to map over a variant given a constraint.
map :: forall c f r. Forall r c => (forall a. c a => a -> f a) -> Var r -> Var (Map f r)
-- | A function to map over a variant given no constraint.
map' :: forall f r. Forall r Unconstrained1 => (forall a. a -> f a) -> Var r -> Var (Map f r)
-- | Lifts a natrual transformation over a variant. In other words, it acts
-- as a variant transformer to convert a variant of f a values
-- to a variant of g a values. If no constraint is needed,
-- instantiate the first type argument with Unconstrained1.
transform :: forall r c (f :: * -> *) (g :: * -> *). Forall r c => (forall a. c a => f a -> g a) -> Var (Map f r) -> Var (Map g r)
-- | A form of transformC that doesn't have a constraint on
-- a
transform' :: forall r (f :: * -> *) (g :: * -> *). Forall r Unconstrained1 => (forall a. f a -> g a) -> Var (Map f r) -> Var (Map g r)
-- | Any structure over a row in which every element is similarly
-- constrained can be metamorphized into another structure over the same
-- row.
class Forall (r :: Row k) (c :: k -> Constraint)
-- | A standard fold
erase :: forall c ρ b. Forall ρ c => (forall a. c a => a -> b) -> Var ρ -> b
-- | A fold with labels
eraseWithLabels :: forall c ρ s b. (Forall ρ c, IsString s) => (forall a. c a => a -> b) -> Var ρ -> (s, b)
-- | A fold over two row type structures at once
eraseZip :: forall c ρ b. Forall ρ c => (forall a. c a => a -> a -> b) -> Var ρ -> Var ρ -> Maybe b
-- | Applicative sequencing over a variant
sequence :: forall f r. (Forall r Unconstrained1, Applicative f) => Var (Map f r) -> f (Var r)
-- | Convert from a variant where two functors have been mapped over the
-- types to one where the composition of the two functors is mapped over
-- the types.
compose :: forall (f :: * -> *) (g :: * -> *) r. Forall r Unconstrained1 => Var (Map f (Map g r)) -> Var (Map (Compose f g) r)
-- | Convert from a variant where the composition of two functors have been
-- mapped over the types to one where the two functors are mapped
-- individually one at a time over the types.
uncompose :: forall (f :: * -> *) (g :: * -> *) r. Forall r Unconstrained1 => Var (Map (Compose f g) r) -> Var (Map f (Map g r))
-- | Return a list of the labels in a row type.
labels :: forall ρ c s. (IsString s, Forall ρ c) => [s]
-- | An unsafe way to make a Variant. This function does not guarantee that
-- the labels are all unique.
unsafeMakeVar :: forall r l. KnownSymbol l => Label l -> (r .! l) -> Var r
-- | A helper function for unsafely adding an element to the front of a
-- variant. This can cause the type of the resulting variant to be
-- malformed, for instance, if the variant already contains labels that
-- are lexicographically before the given label. Realistically, this
-- function should only be used when writing calls to metamorph.
unsafeInjectFront :: forall l a r. KnownSymbol l => Var (R r) -> Var (R ((l :-> a) : r))
instance forall k (cs :: k -> *) (ρ :: Data.Row.Internal.Row *) (m :: GHC.Generics.Meta). Data.Row.Variants.FromNativeExactG cs ρ => Data.Row.Variants.FromNativeExactG (GHC.Generics.D1 m cs) ρ
instance Data.Row.Variants.FromNativeExactG GHC.Generics.V1 Data.Row.Internal.Empty
instance (GHC.TypeLits.KnownSymbol name, ρ Data.Row.Internal.≈ (name Data.Row.Internal..== t)) => Data.Row.Variants.FromNativeExactG (GHC.Generics.C1 ('GHC.Generics.MetaCons name fixity sels) (GHC.Generics.S1 m (GHC.Generics.Rec0 t))) ρ
instance forall k (l :: k -> *) (ρ₁ :: Data.Row.Internal.Row *) (r :: k -> *) (ρ₂ :: Data.Row.Internal.Row *) (ρ :: Data.Row.Internal.Row *). (Data.Row.Variants.FromNativeExactG l ρ₁, Data.Row.Variants.FromNativeExactG r ρ₂, ρ Data.Row.Internal.≈ (ρ₁ Data.Row.Internal..+ ρ₂)) => Data.Row.Variants.FromNativeExactG (l GHC.Generics.:+: r) ρ
instance forall k (cs :: k -> *) (ρ :: Data.Row.Internal.Row *) (m :: GHC.Generics.Meta). Data.Row.Variants.FromNativeG cs ρ => Data.Row.Variants.FromNativeG (GHC.Generics.D1 m cs) ρ
instance Data.Row.Variants.FromNativeG GHC.Generics.V1 ρ
instance (GHC.TypeLits.KnownSymbol name, (ρ Data.Row.Internal..! name) Data.Row.Internal.≈ t, Data.Row.Internal.AllUniqueLabels ρ) => Data.Row.Variants.FromNativeG (GHC.Generics.C1 ('GHC.Generics.MetaCons name fixity sels) (GHC.Generics.S1 m (GHC.Generics.Rec0 t))) ρ
instance forall k (l :: k -> *) (ρ :: Data.Row.Internal.Row *) (r :: k -> *). (Data.Row.Variants.FromNativeG l ρ, Data.Row.Variants.FromNativeG r ρ) => Data.Row.Variants.FromNativeG (l GHC.Generics.:+: r) ρ
instance forall k (cs :: k -> *) (ρ :: Data.Row.Internal.Row *) (m :: GHC.Generics.Meta). Data.Row.Variants.ToNativeG cs ρ => Data.Row.Variants.ToNativeG (GHC.Generics.D1 m cs) ρ
instance Data.Row.Variants.ToNativeG GHC.Generics.V1 Data.Row.Internal.Empty
instance (GHC.TypeLits.KnownSymbol name, ρ Data.Row.Internal.≈ (name Data.Row.Internal..== t)) => Data.Row.Variants.ToNativeG (GHC.Generics.C1 ('GHC.Generics.MetaCons name fixity sels) (GHC.Generics.S1 m (GHC.Generics.Rec0 t))) ρ
instance forall k (l :: k -> *) (ρ₁ :: Data.Row.Internal.Row *) (r :: k -> *) (ρ₂ :: Data.Row.Internal.Row *) (ρ :: Data.Row.Internal.Row *). (Data.Row.Variants.ToNativeG l ρ₁, Data.Row.Variants.ToNativeG r ρ₂, ρ₂ Data.Row.Internal.≈ (ρ Data.Row.Internal..\\ ρ₁), ρ Data.Row.Internal.≈ (ρ₁ Data.Row.Internal..+ ρ₂), Data.Row.Internal.AllUniqueLabels ρ₁, Data.Row.Internal.Forall ρ₂ Data.Row.Internal.Unconstrained1) => Data.Row.Variants.ToNativeG (l GHC.Generics.:+: r) ρ
instance Data.Row.Variants.GenericVar r => GHC.Generics.Generic (Data.Row.Variants.Var r)
instance Data.Row.Variants.GenericVar Data.Row.Internal.Empty
instance GHC.TypeLits.KnownSymbol name => Data.Row.Variants.GenericVar ('Data.Row.Internal.R '[ name 'Data.Row.Internal.:-> t])
instance (Data.Row.Variants.GenericVar ('Data.Row.Internal.R r), GHC.TypeLits.KnownSymbol name, r Data.Type.Equality.~ ((name' 'Data.Row.Internal.:-> t') : r'), Data.Row.Internal.AllUniqueLabels ('Data.Row.Internal.R ((name 'Data.Row.Internal.:-> t) : r))) => Data.Row.Variants.GenericVar ('Data.Row.Internal.R ((name 'Data.Row.Internal.:-> t) : r))
instance Data.Row.Internal.Forall r GHC.Show.Show => GHC.Show.Show (Data.Row.Variants.Var r)
instance Data.Row.Internal.Forall r GHC.Classes.Eq => GHC.Classes.Eq (Data.Row.Variants.Var r)
instance (Data.Row.Internal.Forall r GHC.Classes.Eq, Data.Row.Internal.Forall r GHC.Classes.Ord) => GHC.Classes.Ord (Data.Row.Variants.Var r)
instance Data.Row.Internal.Forall r Control.DeepSeq.NFData => Control.DeepSeq.NFData (Data.Row.Variants.Var r)
instance (Data.Row.Internal.AllUniqueLabels r, Data.Row.Internal.AllUniqueLabels r', GHC.TypeLits.KnownSymbol name, (r Data.Row.Internal..! name) Data.Row.Internal.≈ a, (r' Data.Row.Internal..! name) Data.Row.Internal.≈ b, r' Data.Row.Internal.≈ ((r Data.Row.Internal..- name) Data.Row.Internal..\/ (name Data.Row.Internal..== b))) => Data.Generics.Sum.Constructors.AsConstructor name (Data.Row.Variants.Var r) (Data.Row.Variants.Var r') a b
instance (Data.Row.Internal.AllUniqueLabels r, GHC.TypeLits.KnownSymbol name, (r Data.Row.Internal..! name) Data.Row.Internal.≈ a, r Data.Row.Internal.≈ ((r Data.Row.Internal..- name) Data.Row.Internal..\/ (name Data.Row.Internal..== a))) => Data.Generics.Sum.Constructors.AsConstructor' name (Data.Row.Variants.Var r) a
-- | This module provides the ability to discharge a polymorphic variant
-- using a record that has matching fields.
module Data.Row.Switch
-- | A Var and a Rec can combine if their rows line up
-- properly.
class Switch (v :: Row *) (r :: Row *) x | v x -> r, r x -> v
-- | Given a Variant and a Record of functions from each possible value of
-- the variant to a single output type, apply the correct function to the
-- value in the variant.
switch :: Switch v r x => Var v -> Rec r -> x
-- | The same as switch but with the argument order reversed
caseon :: Switch v r x => Rec r -> Var v -> x
instance Data.Row.Switch.Switch ('Data.Row.Internal.R '[]) ('Data.Row.Internal.R '[]) x
instance (GHC.TypeLits.KnownSymbol l, Data.Row.Switch.Switch ('Data.Row.Internal.R v) ('Data.Row.Internal.R r) b) => Data.Row.Switch.Switch ('Data.Row.Internal.R ((l 'Data.Row.Internal.:-> a) : v)) ('Data.Row.Internal.R ((l 'Data.Row.Internal.:-> (a -> b)) : r)) b
-- | This module includes a set of common functions for Records and
-- Variants. It includes:
--
--