Portability | GHC only |
---|---|
Stability | experimental |
Maintainer | Brent Yorgey <byorgey@cis.upenn.edu> |
Special type combinators for specifying binding structure.
- data Bind p t = B p t
- data Rebind p1 p2 = R p1 p2
- data Rec p = Rec p
- newtype TRec p = TRec (Bind (Rec p) ())
- newtype Embed t = Embed t
- newtype Shift p = Shift p
- module Unbound.LocallyNameless.Name
- rBind :: forall p[a1eRq] t[a1eRr]. (Rep p[a1eRq], Rep t[a1eRr]) => R (Bind p[a1eRq] t[a1eRr])
- rRebind :: forall p1[a1eRo] p2[a1eRp]. (Rep p1[a1eRo], Rep p2[a1eRp]) => R (Rebind p1[a1eRo] p2[a1eRp])
- rEmbed :: forall t[a1eRl]. Rep t[a1eRl] => R (Embed t[a1eRl])
- rRec :: forall p[a1eRn]. Rep p[a1eRn] => R (Rec p[a1eRn])
- rShift :: forall p[a1eRk]. Rep p[a1eRk] => R (Shift p[a1eRk])
Documentation
The most fundamental combinator for expressing binding structure
is Bind
. The term type Bind p t
represents a pattern p
paired with a term t
, where names in p
are bound within t
.
Like Name
, Bind
is also abstract. You can create bindings
using bind
and take them apart with unbind
and friends.
B p t |
(Rep p[a1eRq], Rep t[a1eRr], Sat (ctx[a1eW5] p[a1eRq]), Sat (ctx[a1eW5] t[a1eRr])) => Rep1 ctx[a1eW5] (Bind p[a1eRq] t[a1eRr]) | |
(Subst c b, Subst c a, Alpha a, Alpha b) => Subst c (Bind a b) | |
(Alpha a, Alpha b, Read a, Read b) => Read (Bind a b) | |
(Show a, Show b) => Show (Bind a b) | |
(Rep p[a1eRq], Rep t[a1eRr]) => Rep (Bind p[a1eRq] t[a1eRr]) | |
(Alpha p, Alpha t) => Alpha (Bind p t) |
Rebind
allows for nested bindings. If p1
and p2
are
pattern types, then Rebind p1 p2
is also a pattern type,
similar to the pattern type (p1,p2)
except that p1
scopes over p2
. That is, names within terms embedded in p2
may refer to binders in p1
.
R p1 p2 |
(Rep p1[a1eRo], Rep p2[a1eRp], Sat (ctx[a1eVK] p1[a1eRo]), Sat (ctx[a1eVK] p2[a1eRp])) => Rep1 ctx[a1eVK] (Rebind p1[a1eRo] p2[a1eRp]) | |
(Subst c b, Subst c a, Alpha a, Alpha b) => Subst c (Rebind a b) | |
(Alpha p1, Alpha p2, Eq p2) => Eq (Rebind p1 p2) | Compare for alpha-equality. |
(Show a, Show b) => Show (Rebind a b) | |
(Rep p1[a1eRo], Rep p2[a1eRp]) => Rep (Rebind p1[a1eRo] p2[a1eRp]) | |
(Alpha p, Alpha q) => Alpha (Rebind p q) |
If p
is a pattern type, then Rec p
is also a pattern type,
which is recursive in the sense that p
may bind names in terms
embedded within itself. Useful for encoding e.g. lectrec and
Agda's dot notation.
Rec p |
TRec
is a standalone variant of Rec
: the only difference is
that whereas
is a pattern type, Rec
pTRec p
is a term type. It is isomorphic to
.
Bind
(Rec
p) ()
Note that TRec
corresponds to Pottier's abstraction construct
from alpha-Caml. In this context,
corresponds to
alpha-Caml's Embed
tinner t
, and
corresponds to
alpha-Caml's Shift
(Embed
t)outer t
.
Embed
allows for terms to be embedded within patterns. Such
embedded terms do not bind names along with the rest of the
pattern. For examples, see the tutorial or examples directories.
If t
is a term type, then Embed t
is a pattern type.
Embed
is not abstract since it involves no binding, and hence
it is safe to manipulate directly. To create and destruct
Embed
terms, you may use the Embed
constructor directly.
(You may also use the functions embed
and unembed
, which
additionally can construct or destruct any number of enclosing
Shift
s at the same time.)
Embed t |
Shift the scope of an embedded term one level outwards.
Shift p |
module Unbound.LocallyNameless.Name
Pay no attention to the man behind the curtain
These type representation objects are exported so they can be referenced by auto-generated code. Please pretend they do not exist.