Remove duplication of type definitions across .fst and .fsti in the compiler #2549
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.
Building more on #2512, this PR tweaks the interleaving strategy of .fsti and .fst for the compiler code (i.e.
--MLish
), so that the type definitions need not be duplicated across .fsti and .fst.Problem
In the current compiler code, take
FStar.Syntax.Syntax
for instance, type definitions such asterm
are duplicated in .fsti and .fst. This is a pain, every change has to be done in two places. Whereas in F*, if the clients needs to work with it, the type definition is written only in .fsti. My guess is that earlier our hands were tied by F# compatibility. But now that it is no longer a constraint, we can do better.Changing the interleaving strategy
The main changes are in 392429d commit. They relate to how we interleave when
--MLish
flag is on.val
decls from the.fsti
, ignoring everything else.let
in .fst, we searched for itsval
in the interface declarations, if found, we prefixedlet
with the correspondingval
, else no op.In this PR:
Tycon
andval
from.fsti
.let
in .fst, we first get the prefix type definitions from the interface declarations, then findval
, and typecheck the prefix type definitions,val
, andlet
.Enabling us to get rid of the duplication of types from
.fst
.Additionally, this PR also disallows writing
type t
in interfaces, instead the programmer must write aval
, as is custom in F*.Future work
We still don't enforce the proper ordering of
let
definitions as per theval
declarations in the interface in the compiler code. Ideally, the interleaving code would not treat--MLish
in any special way.But that's some grunt work, leaving for future.