Copyright | (c) Kimiyuki Onaka 2020 |
---|---|
License | Apache License 2.0 |
Maintainer | kimiyuki95@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- substitute :: MonadAlpha m => VarName -> Expr -> Expr -> m Expr
- substituteToplevelExpr :: (MonadAlpha m, MonadError Error m) => VarName -> Expr -> ToplevelExpr -> m ToplevelExpr
Documentation
substitute :: MonadAlpha m => VarName -> Expr -> Expr -> m Expr Source #
substitute
replaces the occrences of the given variable with the given expr. This considers contexts.
>>>
flip evalAlphaT 0 $ substitute (VarName "x") (Lit (LitInt 0)) (Lam (VarName "y") IntTy (Var (VarName "x")))
Lam (VarName "y") IntTy (Lit (LitInt 0))
>>>
flip evalAlphaT 0 $ substitute (VarName "x") (Lit (LitInt 0)) (Lam (VarName "x") IntTy (Var (VarName "x")))
Lam (VarName "x") IntTy (Var (VarName "x"))
substituteToplevelExpr :: (MonadAlpha m, MonadError Error m) => VarName -> Expr -> ToplevelExpr -> m ToplevelExpr Source #