| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
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.