| 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.
Synopsis
- data SubstName a b where
- data SubstCoerce a b where
- SubstCoerce :: Name b -> (b -> Maybe a) -> SubstCoerce a b
- substBind :: Subst a b => Bind (Name a) b -> a -> b
- class Rep1 (SubstD b) a => Subst b a where
- 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
- substPatsR1 :: R1 (SubstD b) a -> Proxy b -> AlphaCtx -> [Dyn] -> a -> a
- substPatR1 :: R1 (SubstD b) a -> AlphaCtx -> b -> a -> a
Documentation
data SubstCoerce a b where Source #
See isCoerceVar
Constructors
| SubstCoerce :: Name b -> (b -> Maybe a) -> SubstCoerce a b |
substBind :: Subst a b => Bind (Name a) b -> a -> b Source #
Immediately substitute for a (single) bound variable in a binder, without first naming that variable.
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.
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.
substPat :: AlphaCtx -> b -> a -> a Source #
substPats :: Proxy b -> AlphaCtx -> [Dyn] -> a -> a Source #