Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Atom (d :: Type) (k :: TYPE r) where
- type (:$:) f x = 'Kon f :@: x
- type (:~:) a b = ('Kon (~) :@: a) :@: b
- type (:~~:) a b = ('Kon (~~) :@: a) :@: b
- data TyVar (d :: Type) (k :: TYPE r) where
- type Var0 = 'Var 'VZ
- type Var1 = 'Var ('VS 'VZ)
- type Var2 = 'Var ('VS ('VS 'VZ))
- type Var3 = 'Var ('VS ('VS ('VS 'VZ)))
- type Var4 = 'Var ('VS ('VS ('VS ('VS 'VZ))))
- type Var5 = 'Var ('VS ('VS ('VS ('VS ('VS 'VZ)))))
- type Var6 = 'Var ('VS ('VS ('VS ('VS ('VS ('VS 'VZ))))))
- type Var7 = 'Var ('VS ('VS ('VS ('VS ('VS ('VS ('VS 'VZ)))))))
- type Var8 = 'Var ('VS ('VS ('VS ('VS ('VS ('VS ('VS ('VS 'VZ))))))))
- type Var9 = 'Var ('VS ('VS ('VS ('VS ('VS ('VS ('VS ('VS ('VS 'VZ)))))))))
- type family Interpret (t :: Atom d k) (tys :: LoT d) :: k where ...
- type family InterpretVar (t :: TyVar d k) (tys :: LoT d) :: k where ...
- type family Satisfies (cs :: [Atom d Constraint]) (tys :: LoT d) :: Constraint where ...
- type family ContainsTyVar (v :: TyVar d k) (t :: Atom d p) :: Bool where ...
- newtype ForAllI (f :: Atom (d1 -> d) Type) (tys :: LoT d) where
- newtype SuchThatI (c :: Atom d Constraint) (f :: Atom d Type) (tys :: LoT d) where
- newtype WrappedI (f :: Atom d Type) (tys :: LoT d) = WrapI {}
- toWrappedI :: forall f tys t. ForAllI f tys -> WrappedI f (t :&&: tys)
- fromWrappedI :: forall f tys. (forall t. WrappedI f (t :&&: tys)) -> ForAllI f tys
Atoms
data Atom (d :: Type) (k :: TYPE r) where Source #
Shape of a type, possibly with type variables.
>>>
:kind Kon [] :@: Var0 -- the type [a] for unknown a
Kon [] :@: Var0 :: Atom (* -> xs) *
Var :: TyVar d k -> Atom d k | Represents a type variable. |
Kon :: k -> Atom d k | Represents a constant type, like |
(:@:) :: Atom d (k1 -> k2) -> Atom d k1 -> Atom d k2 | Represents type application. |
(:&:) :: Atom d Constraint -> Atom d Constraint -> Atom d Constraint infixr 5 | Represents the conjunction of two constraints. |
ForAll :: Atom (d1 -> d) Type -> Atom d Type | Represents universal quantification. |
(:=>>:) :: Atom d Constraint -> Atom d Type -> Atom d Type infixr 5 | Represents constraint requirement, the "thick arrow" |
type (:$:) f x = 'Kon f :@: x Source #
Represents an applied constructor.
Instead of Kon [] :
: Var0$ you can write @[] :$: Var0$.
Type variables
Aliases for specific variables
Intepretation
type family Interpret (t :: Atom d k) (tys :: LoT d) :: k where ... Source #
type family InterpretVar (t :: TyVar d k) (tys :: LoT d) :: k where ... Source #
Obtains the type in the list tys
referenced
by the type variable t
.
>>>
:kind! Interpret Var0 (LoT2 Int Bool)
Interpret Var0 (LoT2 Int Bool) :: * = Int>>>
:kind! Interpret Var1 (LoT2 Int Bool)
Interpret Var1 (LoT2 Int Bool) :: * = Bool
InterpretVar 'VZ tys = HeadLoT tys | |
InterpretVar ('VS v) tys = InterpretVar v (TailLoT tys) |
type family Satisfies (cs :: [Atom d Constraint]) (tys :: LoT d) :: Constraint where ... Source #
Interprets a list of Atoms
representing constraints
into the actual constraints. This is a specialization of
Interpret
for the case of constraints.
>>>
:kind! Satisfies '[Eq :$: Var0, Show :$: Var0] (LoT1 Int)
Satisfies '[Eq :$: Var0, Show :$: Var0] (LoT1 Int) :: Constraint = (Eq Int, (Show Int, () :: Constraint))
type family ContainsTyVar (v :: TyVar d k) (t :: Atom d p) :: Bool where ... Source #
Determines whether a given type variable v
is used within an Atom
t
.
If not, we know that the atom is constant with respect to that variable.
ContainsTyVar v ('Var v) = 'True | |
ContainsTyVar v ('Var w) = 'False | |
ContainsTyVar v ('Kon t) = 'False | |
ContainsTyVar v (f :@: x) = Or (ContainsTyVar v f) (ContainsTyVar v x) | |
ContainsTyVar v (x :&: y) = Or (ContainsTyVar v x) (ContainsTyVar v y) | |
ContainsTyVar v (c :=>>: f) = Or (ContainsTyVar v c) (ContainsTyVar v f) | |
ContainsTyVar v ('ForAll f) = ContainsTyVar ('VS v) f |
Auxiliary types for interpretation
newtype ForAllI (f :: Atom (d1 -> d) Type) (tys :: LoT d) where Source #
newtype SuchThatI (c :: Atom d Constraint) (f :: Atom d Type) (tys :: LoT d) where Source #