Safe Haskell | None |
---|---|
Language | Haskell2010 |
EOT (Either of Tuples) to/from ADT (Algebraic Data Type).
to produce or consume custom ADT with (
and <:>
)(
.<+>
)
This is like what is done in generic-sop
:
https://hackage.haskell.org/package/generics-sop-0.5.1.0/docs/src/Generics.SOP.GGP.html#gSumFrom
but using directly Either
and Tuples
instead of passing by the intermediary GADTs NP
and NS
.
Synopsis
- type family EoT (adt :: [[*]]) :: * where ...
- type family Tuples (as :: [*]) :: r :: * where ...
- type ADT (adt :: *) = ListOfRepSums (Rep adt) '[]
- type family ListOfRepSums (a :: * -> *) (ss :: [[*]]) :: [[*]]
- type family ListOfRepProducts (a :: * -> *) (ps :: [*]) :: [*]
- type family TypeOfRepField (a :: * -> *) :: *
- type RepOfEoT a = RepOfEithers (Rep a) '[]
- adtOfeot :: Generic a => RepOfEoT a => EoT (ADT a) -> a
- class RepOfEithers (a :: * -> *) ss where
- repOfEithers :: EoT (ListOfRepSums a ss) -> (a x -> r) -> (EoT ss -> r) -> r
- class RepOfTuples (a :: * -> *) (xs :: [*]) where
- repOfTuples :: Tuples (ListOfRepProducts a xs) -> (a x -> Tuples xs -> r) -> r
- class RepOfField (a :: * -> *) where
- repOfField :: TypeOfRepField a -> a x
- type EoTOfRep a = EithersOfRep (Rep a) '[]
- eotOfadt :: Generic a => EoTOfRep a => a -> EoT (ADT a)
- class EithersOfRep (a :: * -> *) ss where
- eithersOfRepL :: a x -> EoT (ListOfRepSums a ss)
- eithersOfRepR :: EoT ss -> EoT (ListOfRepSums a ss)
- class TuplesOfRep (a :: * -> *) (ps :: [*]) where
- tuplesOfRep :: a x -> Tuples ps -> Tuples (ListOfRepProducts a ps)
- class FieldOfRep (a :: * -> *) where
- fieldOfRep :: a x -> TypeOfRepField a
Type family EoT
Type family Tuples
type family Tuples (as :: [*]) :: r :: * where ... Source #
Return the type of snd
-nested 2-tuples
from the given list of types.
Type ADT
type ADT (adt :: *) = ListOfRepSums (Rep adt) '[] Source #
Normalized type-level representation of an Algebraic Data Type.
Type family ListOfRepSums
type family ListOfRepSums (a :: * -> *) (ss :: [[*]]) :: [[*]] Source #
Collect the alternatives in a continuation passing-style.
Instances
type ListOfRepSums (V1 :: Type -> Type) ss Source # | Empty datatypes |
Defined in Symantic.ADT | |
type ListOfRepSums (a :+: b) ss Source # | |
Defined in Symantic.ADT | |
type ListOfRepSums (M1 D _c a) ss Source # | Meta-information for datatypes |
Defined in Symantic.ADT | |
type ListOfRepSums (M1 C _c a) ss Source # | Meta-information for constructors |
Defined in Symantic.ADT |
Type family ListOfRepProducts
type family ListOfRepProducts (a :: * -> *) (ps :: [*]) :: [*] Source #
Collect the records in a continuation passing-style.
Instances
type ListOfRepProducts (U1 :: Type -> Type) ps Source # | Constructor without fields |
Defined in Symantic.ADT | |
type ListOfRepProducts (a :*: b) ps Source # | |
Defined in Symantic.ADT | |
type ListOfRepProducts (M1 S _c a) ps Source # | Meta-information for record selectors |
Defined in Symantic.ADT |
Type family TypeOfRepField
type family TypeOfRepField (a :: * -> *) :: * Source #
Instances
type TypeOfRepField (K1 _i a :: Type -> Type) Source # | |
Defined in Symantic.ADT |
Class RepOfEoT
type RepOfEoT a = RepOfEithers (Rep a) '[] Source #
Class RepOfEithers
class RepOfEithers (a :: * -> *) ss where Source #
repOfEithers :: EoT (ListOfRepSums a ss) -> (a x -> r) -> (EoT ss -> r) -> r Source #
Instances
RepOfEithers (V1 :: Type -> Type) ss Source # | |
Defined in Symantic.ADT repOfEithers :: EoT (ListOfRepSums V1 ss) -> (V1 x -> r) -> (EoT ss -> r) -> r Source # | |
(RepOfEithers a (ListOfRepSums b ss), RepOfEithers b ss) => RepOfEithers (a :+: b) ss Source # | |
Defined in Symantic.ADT repOfEithers :: EoT (ListOfRepSums (a :+: b) ss) -> ((a :+: b) x -> r) -> (EoT ss -> r) -> r Source # | |
RepOfEithers a ss => RepOfEithers (M1 D c a) ss Source # | |
Defined in Symantic.ADT repOfEithers :: EoT (ListOfRepSums (M1 D c a) ss) -> (M1 D c a x -> r) -> (EoT ss -> r) -> r Source # | |
RepOfTuples a ('[] :: [Type]) => RepOfEithers (M1 C c a) ('[] :: [[Type]]) Source # | |
Defined in Symantic.ADT repOfEithers :: EoT (ListOfRepSums (M1 C c a) '[]) -> (M1 C c a x -> r) -> (EoT '[] -> r) -> r Source # | |
RepOfTuples a ('[] :: [Type]) => RepOfEithers (M1 C c a) (ps ': ss) Source # | |
Defined in Symantic.ADT repOfEithers :: EoT (ListOfRepSums (M1 C c a) (ps ': ss)) -> (M1 C c a x -> r) -> (EoT (ps ': ss) -> r) -> r Source # |
Class RepOfTuples
class RepOfTuples (a :: * -> *) (xs :: [*]) where Source #
repOfTuples :: Tuples (ListOfRepProducts a xs) -> (a x -> Tuples xs -> r) -> r Source #
Instances
RepOfTuples (U1 :: Type -> Type) ps Source # | |
Defined in Symantic.ADT repOfTuples :: Tuples (ListOfRepProducts U1 ps) -> (U1 x -> Tuples ps -> r) -> r Source # | |
(RepOfTuples a (ListOfRepProducts b ps), RepOfTuples b ps) => RepOfTuples (a :*: b) ps Source # | |
Defined in Symantic.ADT repOfTuples :: Tuples (ListOfRepProducts (a :*: b) ps) -> ((a :*: b) x -> Tuples ps -> r) -> r Source # | |
RepOfField a => RepOfTuples (M1 S c a) ('[] :: [Type]) Source # | |
Defined in Symantic.ADT repOfTuples :: Tuples (ListOfRepProducts (M1 S c a) '[]) -> (M1 S c a x -> Tuples '[] -> r) -> r Source # | |
RepOfField a => RepOfTuples (M1 S c a) (p ': ps) Source # | |
Defined in Symantic.ADT repOfTuples :: Tuples (ListOfRepProducts (M1 S c a) (p ': ps)) -> (M1 S c a x -> Tuples (p ': ps) -> r) -> r Source # |
Class RepOfField
class RepOfField (a :: * -> *) where Source #
repOfField :: TypeOfRepField a -> a x Source #
Instances
RepOfField (K1 i a :: Type -> Type) Source # | |
Defined in Symantic.ADT repOfField :: TypeOfRepField (K1 i a) -> K1 i a x Source # |
Class EoTOfRep
type EoTOfRep a = EithersOfRep (Rep a) '[] Source #
Class EithersOfRep
class EithersOfRep (a :: * -> *) ss where Source #
eithersOfRepL :: a x -> EoT (ListOfRepSums a ss) Source #
eithersOfRepR :: EoT ss -> EoT (ListOfRepSums a ss) Source #
Instances
Class TuplesOfRep
class TuplesOfRep (a :: * -> *) (ps :: [*]) where Source #
tuplesOfRep :: a x -> Tuples ps -> Tuples (ListOfRepProducts a ps) Source #
Instances
TuplesOfRep (U1 :: Type -> Type) ps Source # | |
Defined in Symantic.ADT tuplesOfRep :: U1 x -> Tuples ps -> Tuples (ListOfRepProducts U1 ps) Source # | |
(TuplesOfRep a (ListOfRepProducts b ps), TuplesOfRep b ps) => TuplesOfRep (a :*: b) ps Source # | |
Defined in Symantic.ADT tuplesOfRep :: (a :*: b) x -> Tuples ps -> Tuples (ListOfRepProducts (a :*: b) ps) Source # | |
FieldOfRep a => TuplesOfRep (M1 S c a) ('[] :: [Type]) Source # | |
Defined in Symantic.ADT tuplesOfRep :: M1 S c a x -> Tuples '[] -> Tuples (ListOfRepProducts (M1 S c a) '[]) Source # | |
FieldOfRep a => TuplesOfRep (M1 S c a) (x ': ps) Source # | |
Defined in Symantic.ADT tuplesOfRep :: M1 S c a x0 -> Tuples (x ': ps) -> Tuples (ListOfRepProducts (M1 S c a) (x ': ps)) Source # |
Class FieldOfRep
class FieldOfRep (a :: * -> *) where Source #
fieldOfRep :: a x -> TypeOfRepField a Source #
Instances
FieldOfRep (K1 i a :: Type -> Type) Source # | |
Defined in Symantic.ADT fieldOfRep :: K1 i a x -> TypeOfRepField (K1 i a) Source # |