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

Language.Egison.Type.TypedDesugar

Description

This module implements Phase 8 of the processing flow: TypedDesugar. It orchestrates type-driven transformations on TIExpr (Typed Internal Expressions) by calling specialized expansion modules.

Type-Driven Transformations (Phase 8): 1. Type class dictionary passing (via TypeClassExpand) - Instance selection based on types - Method call concretization 2. Type information optimization and embedding - Preserve type info for better error messages during evaluation - Each node in TIExpr contains its type

Type information is preserved throughout desugaring, enabling: - Better runtime error messages with type information - Type-based dispatch during evaluation - Debugging support with type annotations

Synopsis

Documentation

desugarTypedExprT :: TIExpr -> EvalM TIExpr Source #

Desugar a typed expression (TIExpr) with type-driven transformations This function orchestrates the transformation pipeline: 1. Insert tensorMap where needed (TensorMapInsertion) 2. Expand type class methods (dictionary passing)

The order matters: tensorMap insertion should happen before type class expansion because after tensorMap insertion, argument types (scalar vs tensor) are determined, which allows type class expansion to use unifyStrict for instance selection.

desugarTypedTopExprT :: TITopExpr -> EvalM (Maybe TITopExpr) Source #

Desugar a top-level typed expression (TITopExpr) This is the main entry point for Phase 8 transformations.

desugarTypedTopExprT_TensorMapOnly :: TITopExpr -> EvalM (Maybe TITopExpr) Source #

Desugar a top-level typed expression with TensorMap insertion only This is used for --dump-ti (intermediate dump after TensorMap insertion)

desugarTypedTopExprT_TypeClassOnly :: TITopExpr -> EvalM (Maybe TITopExpr) Source #

Expand type class methods only (assumes TensorMap insertion is already done) This is used internally to perform type class expansion after TensorMap insertion