egison-5.0.0: Programming language with non-linear pattern-matching against non-free data
LicenseMIT
Safe HaskellNone
LanguageGHC2021

Language.Egison.Eval

Description

This module provides interface for evaluating Egison expressions.

Processing Flow (design/implementation.md): 1. TopExpr (Parse result) 2. expandLoads (File loading with caching) 3. Environment Building Phase (Collect data constructors, type classes, instances, type signatures) 4. Desugar (Syntactic desugaring) 5. Type Inference Phase (Constraint generation, unification, type class constraint processing) 6. Type Check Phase (Verify type annotations, check type class constraints) 7. TypedTopExpr (Typed AST) 8. TypedDesugar (Type-driven transformations: type class expansion, tensorMap insertion) 9. TITopExpr (Evaluatable typed IR with type info preserved) 10. Evaluation (Pattern matching execution, expression evaluation, IO actions)

Synopsis

Eval Egison expressions

evalExpr :: Env -> Expr -> EvalM EgisonValue Source #

Evaluate an Egison expression.

evalTopExpr :: Env -> TopExpr -> EvalM (Maybe EgisonValue, Env) Source #

Evaluate an Egison top expression. Implements the complete processing flow: expandLoads → Environment Building → Desugar → Type Inference/Check → TypedDesugar → Evaluation

evalTopExprStr :: Env -> TopExpr -> EvalM (Maybe String, Env) Source #

Evaluate an Egison top expression.

evalTopExprs :: Env -> [TopExpr] -> EvalM Env Source #

Evaluate Egison top expressions. Pipeline: ExpandLoads → TypeCheck → TypedDesugar → Eval

evalTopExprs' :: Env -> [TopExpr] -> Bool -> Bool -> EvalM Env Source #

Evaluate Egison top expressions with control over printing and dumping.

evalTopExprsNoPrint :: Env -> [TopExpr] -> EvalM Env Source #

Evaluate Egison top expressions without printing. Pipeline: ExpandLoads → TypeCheck → TypedDesugar → Eval

runExpr :: Env -> String -> EvalM EgisonValue Source #

Evaluate an Egison expression. Input is a Haskell string.

runTopExpr :: Env -> String -> EvalM (Maybe EgisonValue, Env) Source #

Evaluate an Egison top expression. Input is a Haskell string.

runTopExprStr :: Env -> String -> EvalM (Maybe String, Env) Source #

Evaluate an Egison top expression. Input is a Haskell string.

runTopExprs :: Env -> String -> EvalM Env Source #

Evaluate Egison top expressions. Input is a Haskell string.

Load Egison files

loadEgisonLibrary :: Env -> FilePath -> EvalM Env Source #

Load an Egison library.

loadEgisonFile :: Env -> FilePath -> EvalM Env Source #

Load an Egison file.

Load expansion

expandLoads :: [TopExpr] -> EvalM [TopExpr] Source #

Expand all Load/LoadFile statements recursively into a flat list of TopExprs. Files are loaded recursively and deduplicated (same file loaded multiple times will only appear once in the final list).