Safe Haskell | None |
---|
- class SpineOf ts where
- spine :: ts
- type :-: t ts = (Proxy t, ts)
- type :-! t1 t2 = (Proxy t1, (Proxy t2, ()))
- module Data.Proxy
- proxyTypeOf :: a -> Proxy a
Constructing a type's Spine
The "spine" of some Shapely
instance type can be specified by
enumerating the types of its recursive subterms in a Product
of Proxy
values. For instance the spine of data L = Cons Int L | Empty
would simply
be
(Proxy :: Proxy L, ())
When parameterized types make up the recursive structure, like [a]
one can
specify the spine using just the base type (in this case []
), e.g.
(Proxy :: Proxy [], ())
...or the base type applied as far as desired and functions using this spine
will match potential product terms accordingly (e.g. coerceWith
).
See proxy-kindness for utilities useful fo constructing Spine
s, e.g.
unappliedOf
.
Allows for terse definition of the cluster of types that make up a type's spine. E.g.
sp = spine :: (Foo ':-:' Bar ':-!' Baz)
Working with Proxys
module Data.Proxy
proxyTypeOf :: a -> Proxy aSource
proxyTypeOf = return