Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interop with generics-sop
generics
Synopsis
- newtype Field (f :: Type -> Type) (field :: (Symbol, Type)) where
- fromSOP :: SListI (MetadataOf a) => NP (Field f) (MetadataOf a) -> Rep f a
- toSOP :: SListI (MetadataOf a) => Rep f a -> Maybe (NP (Field f) (MetadataOf a))
- toDictAll :: forall f a c. (Generic a, Constraints a (Compose c f), All IsField (MetadataOf a), forall nm x. c (f x) => c (Field f '(nm, x))) => Proxy f -> Proxy a -> Proxy c -> Dict (All (Compose c (Field f))) (MetadataOf a)
- glowerBound :: (Generic a, All LowerBound xs, Code a ~ '[xs]) => a
Documentation
Translate between SOP representation and large-records representation
newtype Field (f :: Type -> Type) (field :: (Symbol, Type)) where Source #
fromSOP :: SListI (MetadataOf a) => NP (Field f) (MetadataOf a) -> Rep f a Source #
toSOP :: SListI (MetadataOf a) => Rep f a -> Maybe (NP (Field f) (MetadataOf a)) Source #
Translate constraints
toDictAll :: forall f a c. (Generic a, Constraints a (Compose c f), All IsField (MetadataOf a), forall nm x. c (f x) => c (Field f '(nm, x))) => Proxy f -> Proxy a -> Proxy c -> Dict (All (Compose c (Field f))) (MetadataOf a) Source #
Translate constraints
When using toSOP
, if you start with something of type
Rep f a
you end up with something of type
NP (Field f) (MetadataOf a)
When doing so, toDictAll
can translate
Constraints a (Compose c f)
(which is useful over the original representation) to
All (Compose c (Field f)) (MetadataOf a)
which is useful for the translated representation.
Additional SOP functions
glowerBound :: (Generic a, All LowerBound xs, Code a ~ '[xs]) => a Source #