| License | BSD-like (see LICENSE) |
|---|---|
| Maintainer | Brent Yorgey <byorgey@cis.upenn.edu> |
| Portability | GHC only (-XKitchenSink) |
| Safe Haskell | None |
| Language | Haskell2010 |
Unbound.LocallyNameless.Subst
Description
The Subst type class for generic capture-avoiding substitution.
- data SubstName a b where
- data SubstCoerce a b where
- SubstCoerce :: Name b -> (b -> Maybe a) -> SubstCoerce a b
- class Rep1 (SubstD b) a => Subst b a where
- isvar :: a -> Maybe (SubstName a b)
- isCoerceVar :: a -> Maybe (SubstCoerce a b)
- subst :: Name b -> b -> a -> a
- substs :: [(Name b, b)] -> a -> a
- data SubstD b a = SubstD {}
- substDefault :: Rep1 (SubstD b) a => Name b -> b -> a -> a
- substR1 :: R1 (SubstD b) a -> Name b -> b -> a -> a
- substsR1 :: R1 (SubstD b) a -> [(Name b, b)] -> a -> a
Documentation
data SubstCoerce a b where Source
See isCoerceVar
Constructors
| SubstCoerce :: Name b -> (b -> Maybe a) -> SubstCoerce a b |
class Rep1 (SubstD b) a => Subst b a where Source
The Subst class governs capture-avoiding substitution. To
derive this class, you only need to indicate where the variables
are in the data type, by overriding the method isvar.
Minimal complete definition
Nothing
Methods
isvar :: a -> Maybe (SubstName a b) Source
This is the only method which normally needs to be implemented
explicitly. If the argument is a variable, return its name
wrapped in the SubstName constructor. Return Nothing for
non-variable arguments. The default implementation always
returns Nothing.
isCoerceVar :: a -> Maybe (SubstCoerce a b) Source
This is an alternative version to isvar, useable in the case
that the substituted argument doesn't have *exactly* the same type
as the term it should be substituted into.
The default implementation always returns Nothing.
subst :: Name b -> b -> a -> a Source
substitutes subst nm sub tmsub for nm in tm. It has
a default generic implementation in terms of isvar.
substs :: [(Name b, b)] -> a -> a Source
Perform several simultaneous substitutions. This method also
has a default generic implementation in terms of isvar.
Instances
| Subst b AnyName Source | |
| Subst b Double Source | |
| Subst b Float Source | |
| Subst b Integer Source | |
| Subst b Char Source | |
| Subst b () Source | |
| Subst b Bool Source | |
| Subst b Int Source | |
| (Alpha a, Subst c a) => Subst c (Rec a) Source | |
| Subst c a => Subst c (Embed a) Source | |
| Subst c a => Subst c (Shift a) Source | |
| Subst c a => Subst c (Maybe a) Source | |
| Subst c a => Subst c [a] Source | |
| Rep a => Subst b (Name a) Source | |
| Rep a => Subst b (R a) Source | |
| (Subst c b, Subst c a, Alpha a, Alpha b) => Subst c (Rebind a b) Source | |
| (Subst c a, Subst c b) => Subst c (Either a b) Source | |
| (Subst c a, Subst c b) => Subst c (a, b) Source | |
| (Subst c a, Subst c b, Subst c d) => Subst c (a, b, d) Source | |
| (Rep order, Rep card, Subst c b, Subst c a, Alpha a, Alpha b) => Subst c (GenBind order card a b) Source | |
| (Subst c a, Subst c b, Subst c d, Subst c e) => Subst c (a, b, d, e) Source | |
| (Subst c a, Subst c b, Subst c d, Subst c e, Subst c f) => Subst c (a, b, d, e, f) Source |
substDefault :: Rep1 (SubstD b) a => Name b -> b -> a -> a Source