| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Language.Egison.Type.TypeClassExpand
Description
This module expands type class method calls using type information from TIExpr. It transforms TIExpr to TIExpr, replacing type class method calls with dictionary-based dispatch.
Pipeline: Phase 8 (TypedDesugar) - TypeClassExpand (first step) This is executed before TensorMapInsertion to resolve type class methods to concrete functions first.
For example, if we have: class Eq a where (==) : a -> a -> Bool instance Eq Integer where (==) x y := x = y
Then a call like: autoEq 1 2 (with type constraint: Eq Integer) becomes: eqIntegerEq 1 2 (dictionary-based dispatch)
This eliminates the need for runtime dispatch functions like resolveEq.
Synopsis
- expandTypeClassMethodsT :: TIExpr -> EvalM TIExpr
- expandTypeClassMethodsInPattern :: TIPattern -> EvalM TIPattern
- addDictionaryParametersT :: TypeScheme -> TIExpr -> EvalM TIExpr
- applyConcreteConstraintDictionaries :: TIExpr -> EvalM TIExpr
- applyConcreteConstraintDictionariesInPattern :: TIPattern -> EvalM TIPattern
Documentation
expandTypeClassMethodsT :: TIExpr -> EvalM TIExpr Source #
Expand type class method calls in a typed expression (TIExpr) This function recursively processes TIExpr and replaces type class method calls with dictionary-based dispatch.
expandTypeClassMethodsInPattern :: TIPattern -> EvalM TIPattern Source #
Expand type class method calls in patterns This is a public wrapper for expandTIPattern used by TypedDesugar
addDictionaryParametersT :: TypeScheme -> TIExpr -> EvalM TIExpr Source #
Add dictionary parameters to a function based on its type scheme constraints This transforms constrained functions into dictionary-passing style