Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Giml.Types.Infer.Substitute
Description
Apply a substitution to a type
Synopsis
- substitute :: Substitute m => Data f => Substitution -> f -> m f
- substituteConstraints :: Substitute m => Substitution -> [ConstraintA] -> m [ConstraintA]
- substituteSubs :: Substitute m => Substitution -> Substitution -> m Substitution
- type Substitute m = MonadError TypeErrorA m
- replaceTypeVar :: Substitute m => Substitution -> Type -> m Type
- mergeVariants :: Substitute m => InputAnn -> [(Constr, Type)] -> Type -> m Type
- mergeRecords :: Substitute m => InputAnn -> [(Label, Type)] -> Type -> m Type
- occursCheck :: Substitute m => TypeVar -> InputAnn -> Type -> m Type
- generalizeTermDef :: TermDef Ann -> TermDef Ann
- generalizeAndClose :: Type -> Type
- generalizeType :: Type -> ([TypeVar], Map TypeVar TypeVar)
- closeType :: [TypeVar] -> Map TypeVar TypeVar -> Type -> Type
- freeVars :: Type -> Set TypeVar
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.
mergeVariants :: Substitute m => InputAnn -> [(Constr, Type)] -> Type -> m Type Source #
mergeRecords :: Substitute m => InputAnn -> [(Label, Type)] -> Type -> m Type Source #
occursCheck :: Substitute m => TypeVar -> InputAnn -> Type -> m Type Source #
protect against infinite types
Generalize
generalizeAndClose :: Type -> Type Source #