Apply functor instantiation map to types #1592
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a functor contains both a newtype and a type synonym referring to the newtype, then during instantiation we must apply the instantiation map to the types in the functor, so that the type synonym now refers to the instantiated newtype instead. Previously, we only applied type substitutions to the types in the functor, which would replace type variables with concrete types defined in the functor arguments, but would not replace any actual names.
Confusingly, the code referred to the instantiation map as "value substitutions" even though it can contain names in the type namespace. The "type substitutions" and "value substitutions" are better thought of as "
TVar -> Type
mappings" and "Name -> Name
mappings". I have renamed them to better reflect this.Fixes #1590.