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

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

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

applyConcreteConstraintDictionaries :: TIExpr -> EvalM TIExpr Source #

Apply dictionaries to expressions with concrete type constraints This is used for top-level definitions like: def integer : Matcher Integer := eq where the right-hand side (eq) has concrete type constraints {Eq Integer}

applyConcreteConstraintDictionariesInPattern :: TIPattern -> EvalM TIPattern Source #

Apply dictionaries to expressions with concrete constraints in patterns This is used to apply dictionaries to value patterns like #(n + 1)