proxy-kindness-0.1: A library for kind-polymorphic manipulation and inspection of Proxy values

Safe HaskellNone





NOTE: All classes here should be considered closed.

Manipulating Proxy types

class Applied t tab | t -> tab whereSource

A relation between a (maybe-partially-applied) type and that type fully applied.


applied :: Proxy t -> Proxy tabSource

Fully apply a type t with polymorphic arguments, yielding tab.


~ * t tab => Applied * t tab 
Applied k (t a) tab => Applied (k1 -> k) t tab 

class Unapplied ptab t | ptab -> t whereSource

A relation between a (maybe-partially-applied) type and that type stripped of all its arguments.

When the bare type is ambiguous (e.g. unapplied (p :: Proxy (m a))), an overlapping instances type error will be raised.


unapplied :: ptab -> Proxy tSource

Given a Proxy tab, strip away all of its arguments, leaving the type t.


~ * pt (Proxy k t) => Unapplied k pt t 
Unapplied k (Proxy (k2 -> k1) ta) t => Unapplied k (Proxy k1 (ta b)) t 

Composing and decomposing Proxy types

unap :: Proxy (t a) -> (Proxy t, Proxy a)Source

ap :: Proxy t -> Proxy a -> Proxy (t a)Source

Using proxy types with real values

asApplied :: Applied ta tab => tab -> Proxy ta -> tabSource

Force the first argument to the fully applied proxy type of the second, e.g.

>>> let x = (Left 1) `asApplied` (Proxy :: Proxy (Either Double))
>>> :t x
x :: Either Double a

unappliedOf :: Unapplied (Proxy tab) t => tab -> Proxy tSource

Create a proxy value for the completely unapplied type of tab

Predicate classes

class IsOfBaseType t tab b | t tab -> bSource

A predicate class that returns True when t is a partially-applied "prefix" type of tab, i.e. tab can be unap-ed to t.


~ Bool false False => IsOfBaseType k k1 t x false 
IsOfBaseType k k t t True 
IsOfBaseType k (k2 -> k1) t ta bool => IsOfBaseType k k1 t (ta b) bool 
IsOfBaseType k k (t a) (t a) True 

class AreEqUnapplied ta tb b | ta tb -> bSource

A predicate class that returns True when the unapplied base type of ta and tb are identical.


(Unapplied k (Proxy k1 ta) t, IsOfBaseType k k2 t tb b) => AreEqUnapplied k1 k2 ta tb b