ocaml-gospel / gospel

A tool-agnostic formal specification language for OCaml.
https://ocaml-gospel.github.io/gospel
MIT License
118 stars 16 forks source link

Make the Gospel type-checker modular #377

Open shym opened 5 months ago

shym commented 5 months ago

Currently, when the type checker encounters a dependency, it will load and type it on the fly. So common dependencies get type-checked over and over again, uselessly. It would be nice to modularize the type-checker so that typing a module requires the digested type information of its dependencies instead of retyping them. This could be done either with dedicated type files (see #376) or trying to piggy-back on current OCaml infrastructure by storing this information in standard files (it would be possible at least in .cmti files, by encoding the information as a special global attribute; could be done in cmi files?).

The expected benefits would be:

n-osborne commented 5 months ago

Thank you @shym for raising this issue.

As we plan to soon use ortac on larger projects this is a good time to work on performance.

This would also remove some blockers for dune integration.

I've begun to experiment with different approaches:

shym commented 5 months ago
  • gospel type checking can't take any arguments (as it is in a ppx)

It can still grab info from environment variables, I expect, which could give us a way to feed it the information we need (namely the paths where to look for dependencies, or is there something else?).

n-osborne commented 5 months ago

You are right, this doesn't make this option impossible. I just think that it may make things a bit more delicate.

n-osborne commented 5 months ago

Modularizing the type-checker is expected to break how unicity of identifier is guaranteed in the current implementation. I've raised #381 for discussing this particular topic.