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.
Before this change, types used in a term would be evaluated away to their corresponding contract (a function) automatically. Note that the only meaningful usage of types right now is to pass them as argument for
std.contract.apply
.This eager conversion loses information; either for error messages (for example, using a type in the wrong place will complain that something has type "function" and might point to inside Nickel internals instead of the actual user-written type). Moreover, in preparation for boolean combinators for contracts, we want to be able to remember the original form of a type as much as possible.
Finally, it might be useful for users to introspect types as well, for example to implement custom contract combinators.
For all these reasons, and because there's no apparent drawback, this commit makes type normal values, that aren't evaluated further. A new case in the
%contrat/apply%
primop simply performs the conversion to contract lazily, once they are actually applied, instead of where they are defined.%typeof%
andstd.typeof
are updated accordingly with the new'Type
tag.Related: #1466, #1460