giml-language-0.1.0.0: A purely functional programming language with emphasis on structural typing
Safe HaskellSafe-Inferred
LanguageGHC2021

Language.Giml.Types.Infer.Substitute

Description

Apply a substitution to a type

Synopsis

Substitute

API

substitute :: Substitute m => Data f => Substitution -> f -> m f Source #

Replaces all type variables for any data type that has an instance of Data using uniplate magic.

Note: uniplate magic = slow.

substituteConstraints :: Substitute m => Substitution -> [ConstraintA] -> m [ConstraintA] Source #

Replaces all type variables for constraints.

substituteSubs :: Substitute m => Substitution -> Substitution -> m Substitution Source #

Replaces all type variables for substitutions.

Types

type Substitute m = MonadError TypeErrorA m Source #

Monadic capabilities of Substitute

Algorithm

replaceTypeVar :: Substitute m => Substitution -> Type -> m Type Source #

Find type variables that appear in the substitution and replace them.

occursCheck :: Substitute m => TypeVar -> InputAnn -> Type -> m Type Source #

protect against infinite types

Generalize