Jikka-5.0.11.1: 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.FreeVars

Description

 
Synopsis

Documentation

isFreeVar :: VarName -> Expr -> Bool Source #

isFreeVar checks if the given variable occurs in the tiven expr. This considers contexts.

>>> VarName "x" `isFreeVar` Lam (VarName "y") IntTy (Var (VarName "x"))
True
>>> VarName "x" `isFreeVar` Lam (VarName "x") IntTy (Var (VarName "x"))
False

isUnusedVar :: VarName -> Expr -> Bool Source #

isUnusedVar is the negation of isFreeVar.

TODO: rename to isNonFreeVar?

isFreeVarOrScopedVar :: VarName -> Expr -> Bool Source #

isFreeVarOrScopedVar checks if the given variable occurs in the tiven expr. This ignores contexts.

>>> VarName "x" `isFreeVarOrScopedVar` Lam (VarName "x") IntTy (Var (VarName "y"))
True