| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Language.Egison.Core
Description
This module implements Phase 10: Evaluation. It provides functions to evaluate expressions and perform pattern matching.
Evaluation Phase (Phase 10): - Pattern matching execution (patternMatch function) * Egison's powerful non-linear pattern matching with backtracking * Pattern matching is NOT desugared but executed during evaluation - Expression evaluation (evalExprShallow, evalExprDeep) - IO action execution - WHNF (Weak Head Normal Form) evaluation
Design Note (design/implementation.md): Pattern matching is processed during evaluation, not during desugaring. This allows Egison's sophisticated pattern matching features to be implemented directly in the evaluator, keeping the desugaring phase simple.
Synopsis
- evalExprShallow :: Env -> IExpr -> EvalM WHNFData
- evalExprDeep :: Env -> IExpr -> EvalM EgisonValue
- evalWHNF :: WHNFData -> EvalM EgisonValue
- valueToType :: EgisonValue -> Type
- whnfToType :: WHNFData -> Type
- recursiveBind :: Env -> [(Var, IExpr)] -> EvalM Env
- recursiveBindPatFuncs :: Env -> [(String, IExpr)] -> EvalM Env
- recursiveBindAll :: Env -> [(Var, IExpr)] -> [(String, IExpr)] -> EvalM Env
- makeBindings' :: [String] -> [ObjectRef] -> [Binding]
- patternMatch :: PMMode -> Env -> IPattern -> WHNFData -> Matcher -> EvalM (MList EvalM Match)
Evaluation
evalExprDeep :: Env -> IExpr -> EvalM EgisonValue Source #
Type utilities
valueToType :: EgisonValue -> Type Source #
Get the Type of an EgisonValue Used for type class method dispatch
whnfToType :: WHNFData -> Type Source #
Get the Type of a WHNFData This extracts type information from WHNF without fully evaluating
Environment
recursiveBindPatFuncs :: Env -> [(String, IExpr)] -> EvalM Env Source #
Bind pattern function definitions into the pattern function environment.
Analogous to recursiveBind but uses the separate PatFuncEnv so that
pattern functions never pollute the regular value environment.
Supports mutual recursion among pattern functions.
recursiveBindAll :: Env -> [(Var, IExpr)] -> [(String, IExpr)] -> EvalM Env Source #
Bind regular value definitions and pattern function definitions together in one step, so that all thunks are closed over a single environment that contains both regular values (in the normal env layers) and pattern functions (in the patFuncEnv). This is necessary for mutual visibility: ordinary definitions can invoke pattern functions (e.g. in matchAll expressions), and pattern functions can invoke other pattern functions.