Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Constrained.Generic
Description
How can we automatically inject normal Haskell types into the logic, using GHC.Generics
Synopsis
- data Prod a b = Prod {}
- type family ProdOver as where ...
- listToProd ∷ (ProdOver as → r) → List Identity as → r
- prodToList ∷ ∀ as. TypeList as ⇒ ProdOver as → List Identity as
- appendProd ∷ ∀ xs ys. (TypeList xs, TypeList ys) ⇒ ProdOver xs → ProdOver ys → ProdOver (Append xs ys)
- splitProd ∷ ∀ xs ys. (TypeList xs, TypeList ys) ⇒ ProdOver (Append xs ys) → Prod (ProdOver xs) (ProdOver ys)
- data Sum a b
- type family SumOver as where ...
- class Typeable (SimpleRep a) ⇒ HasSimpleRep a where
- type SimpleRep a
- type TheSop a ∷ [Type]
- toSimpleRep ∷ a → SimpleRep a
- fromSimpleRep ∷ SimpleRep a → a
- type family SimplifyRep f where ...
- class SimpleGeneric rep where
- toSimpleRep' ∷ rep p → SimplifyRep rep
- fromSimpleRep' ∷ SimplifyRep rep → rep p
- data (c ∷ Symbol) ::: (ts ∷ [Type])
- type family SOPOf f where ...
- type family Constr f where ...
- type family SOP constrs where ...
- type family ConstrOf c sop where ...
- class Inject c constrs r where
- inject ∷ ∀ c constrs. Inject c constrs (SOP constrs) ⇒ FunTy (ConstrOf c constrs) (SOP constrs)
- type family ALG constrs r where ...
- class SOPLike constrs r where
- class SimpleConstructor rep where
- toSimpleCon' ∷ rep p → ProdOver (Constr rep)
- fromSimpleCon' ∷ ProdOver (Constr rep) → rep p
- class SopList xs ys where
Documentation
Instances
listToProd ∷ (ProdOver as → r) → List Identity as → r Source #
appendProd ∷ ∀ xs ys. (TypeList xs, TypeList ys) ⇒ ProdOver xs → ProdOver ys → ProdOver (Append xs ys) Source #
splitProd ∷ ∀ xs ys. (TypeList xs, TypeList ys) ⇒ ProdOver (Append xs ys) → Prod (ProdOver xs) (ProdOver ys) Source #
Generic way to represent Sums
Instances
class Typeable (SimpleRep a) ⇒ HasSimpleRep a where Source #
Minimal complete definition
Nothing
Associated Types
Methods
toSimpleRep ∷ a → SimpleRep a Source #
default toSimpleRep ∷ (Generic a, SimpleGeneric (Rep a), SimpleRep a ~ SimplifyRep (Rep a)) ⇒ a → SimpleRep a Source #
fromSimpleRep ∷ SimpleRep a → a Source #
default fromSimpleRep ∷ (Generic a, SimpleGeneric (Rep a), SimpleRep a ~ SimplifyRep (Rep a)) ⇒ SimpleRep a → a Source #
Instances
HasSimpleRep Foo Source # | |
HasSimpleRep Three Source # | |
HasSimpleRep FooBarBaz Source # | |
HasSimpleRep () Source # | |
Defined in Constrained.Base | |
HasSimpleRep Bool Source # | |
Defined in Constrained.TheKnot | |
(Typeable a, Ord a) ⇒ HasSimpleRep (NotASet a) Source # | |
Typeable a ⇒ HasSimpleRep (Maybe a) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ Maybe a → SimpleRep (Maybe a) Source # fromSimpleRep ∷ SimpleRep (Maybe a) → Maybe a Source # | |
(Typeable a, Typeable b) ⇒ HasSimpleRep (Either a b) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ Either a b → SimpleRep (Either a b) Source # fromSimpleRep ∷ SimpleRep (Either a b) → Either a b Source # | |
(Typeable a, Typeable b) ⇒ HasSimpleRep (a, b) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b) → SimpleRep (a, b) Source # fromSimpleRep ∷ SimpleRep (a, b) → (a, b) Source # | |
(Typeable a, Typeable b, Typeable c) ⇒ HasSimpleRep (a, b, c) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b, c) → SimpleRep (a, b, c) Source # fromSimpleRep ∷ SimpleRep (a, b, c) → (a, b, c) Source # | |
(Typeable a, Typeable b, Typeable c, Typeable d) ⇒ HasSimpleRep (a, b, c, d) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b, c, d) → SimpleRep (a, b, c, d) Source # fromSimpleRep ∷ SimpleRep (a, b, c, d) → (a, b, c, d) Source # | |
(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e) ⇒ HasSimpleRep (a, b, c, d, e) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b, c, d, e) → SimpleRep (a, b, c, d, e) Source # fromSimpleRep ∷ SimpleRep (a, b, c, d, e) → (a, b, c, d, e) Source # | |
(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable g) ⇒ HasSimpleRep (a, b, c, d, e, g) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b, c, d, e, g) → SimpleRep (a, b, c, d, e, g) Source # fromSimpleRep ∷ SimpleRep (a, b, c, d, e, g) → (a, b, c, d, e, g) Source # | |
(Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable g, Typeable h) ⇒ HasSimpleRep (a, b, c, d, e, g, h) Source # | |
Defined in Constrained.Spec.SumProd Methods toSimpleRep ∷ (a, b, c, d, e, g, h) → SimpleRep (a, b, c, d, e, g, h) Source # fromSimpleRep ∷ SimpleRep (a, b, c, d, e, g, h) → (a, b, c, d, e, g, h) Source # |
type family SimplifyRep f where ... Source #
Equations
SimplifyRep f = SOP (SOPOf f) |
class SimpleGeneric rep where Source #
Methods
toSimpleRep' ∷ rep p → SimplifyRep rep Source #
fromSimpleRep' ∷ SimplifyRep rep → rep p Source #
Instances
(SimpleGeneric f, SimpleGeneric g, SopList (SOPOf f) (SOPOf g)) ⇒ SimpleGeneric (f :+: g) Source # | |
Defined in Constrained.Generic Methods toSimpleRep' ∷ (f :+: g) p → SimplifyRep (f :+: g) Source # fromSimpleRep' ∷ SimplifyRep (f :+: g) → (f :+: g) p Source # | |
SimpleConstructor f ⇒ SimpleGeneric (C1 ('MetaCons c a b) f) Source # | |
Defined in Constrained.Generic Methods toSimpleRep' ∷ C1 ('MetaCons c a b) f p → SimplifyRep (C1 ('MetaCons c a b) f) Source # fromSimpleRep' ∷ SimplifyRep (C1 ('MetaCons c a b) f) → C1 ('MetaCons c a b) f p Source # | |
SimpleGeneric f ⇒ SimpleGeneric (D1 d f) Source # | |
Defined in Constrained.Generic Methods toSimpleRep' ∷ D1 d f p → SimplifyRep (D1 d f) Source # fromSimpleRep' ∷ SimplifyRep (D1 d f) → D1 d f p Source # |
data (c ∷ Symbol) ::: (ts ∷ [Type]) Source #
A constructor name with the types of its arguments
Instances
TypeList prod ⇒ Inject c ((c ::: prod) ': (prod' ': constrs)) r Source # | |
TypeList prod ⇒ Inject c '[c ::: prod] r Source # | |
(FunTy (ConstrOf c ((c' ::: prod) ': (con ': constrs))) r ~ FunTy (ConstrOf c (con ': constrs)) r, Inject c (con ': constrs) r) ⇒ Inject c ((c' ::: prod) ': (con ': constrs)) r Source # | |
(TypeList prod, SOPLike (con ': cases) r) ⇒ SOPLike ((c ::: prod) ': (con ': cases)) r Source # | |
TypeList prod ⇒ SOPLike '[c ::: prod] r Source # | |
SopList (x' ': xs) (y ': ys) ⇒ SopList ((c ::: x) ': (x' ': xs)) (y ': ys) Source # | |
Defined in Constrained.Generic Methods injectSOPLeft ∷ SOP ((c ::: x) ': (x' ': xs)) → SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) Source # injectSOPRight ∷ SOP (y ': ys) → SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) Source # caseSOP ∷ SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) → Sum (SOP ((c ::: x) ': (x' ': xs))) (SOP (y ': ys)) Source # | |
SopList '[c ::: x] (y ': ys) Source # | |
class Inject c constrs r where Source #
Instances
TypeList prod ⇒ Inject c ((c ::: prod) ': (prod' ': constrs)) r Source # | |
TypeList prod ⇒ Inject c '[c ::: prod] r Source # | |
(FunTy (ConstrOf c ((c' ::: prod) ': (con ': constrs))) r ~ FunTy (ConstrOf c (con ': constrs)) r, Inject c (con ': constrs) r) ⇒ Inject c ((c' ::: prod) ': (con ': constrs)) r Source # | |
inject ∷ ∀ c constrs. Inject c constrs (SOP constrs) ⇒ FunTy (ConstrOf c constrs) (SOP constrs) Source #
type family ALG constrs r where ... Source #
An `ALG constrs r` is a function that takes a way to turn every
constructor into an r
:
```
ALG (SOPOf (Rep (Either Int Bool))) r = (Int -> r) -> (Bool -> r) -> r
```
class SOPLike constrs r where Source #
Methods
algebra ∷ SOP constrs → ALG constrs r Source #
Run a SOP
consts ∷ r → ALG constrs r Source #
Ignore everything in the SOP
class SimpleConstructor rep where Source #
Methods
toSimpleCon' ∷ rep p → ProdOver (Constr rep) Source #
fromSimpleCon' ∷ ProdOver (Constr rep) → rep p Source #
Instances
SimpleConstructor (U1 ∷ Type → Type) Source # | |
Defined in Constrained.Generic Methods toSimpleCon' ∷ U1 p → ProdOver (Constr U1) Source # fromSimpleCon' ∷ ProdOver (Constr U1) → U1 p Source # | |
(SimpleConstructor f, SimpleConstructor g, TypeList (Constr f), TypeList (Constr g)) ⇒ SimpleConstructor (f :*: g) Source # | |
Defined in Constrained.Generic Methods toSimpleCon' ∷ (f :*: g) p → ProdOver (Constr (f :*: g)) Source # fromSimpleCon' ∷ ProdOver (Constr (f :*: g)) → (f :*: g) p Source # | |
SimpleConstructor (K1 i k ∷ Type → Type) Source # | |
Defined in Constrained.Generic Methods toSimpleCon' ∷ K1 i k p → ProdOver (Constr (K1 i k)) Source # fromSimpleCon' ∷ ProdOver (Constr (K1 i k)) → K1 i k p Source # | |
SimpleConstructor f ⇒ SimpleConstructor (S1 s f) Source # | |
Defined in Constrained.Generic Methods toSimpleCon' ∷ S1 s f p → ProdOver (Constr (S1 s f)) Source # fromSimpleCon' ∷ ProdOver (Constr (S1 s f)) → S1 s f p Source # |
class SopList xs ys where Source #
Construct and deconstruct cases in a SOP
Methods
injectSOPLeft ∷ SOP xs → SOP (Append xs ys) Source #
injectSOPRight ∷ SOP ys → SOP (Append xs ys) Source #
caseSOP ∷ SOP (Append xs ys) → Sum (SOP xs) (SOP ys) Source #
Instances
SopList (x' ': xs) (y ': ys) ⇒ SopList ((c ::: x) ': (x' ': xs)) (y ': ys) Source # | |
Defined in Constrained.Generic Methods injectSOPLeft ∷ SOP ((c ::: x) ': (x' ': xs)) → SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) Source # injectSOPRight ∷ SOP (y ': ys) → SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) Source # caseSOP ∷ SOP (Append ((c ::: x) ': (x' ': xs)) (y ': ys)) → Sum (SOP ((c ::: x) ': (x' ': xs))) (SOP (y ': ys)) Source # | |
SopList '[c ::: x] (y ': ys) Source # | |