Jikka-5.0.11.2: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2020
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.Core.Language.Beta

Description

 
Synopsis

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"))