Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize instantiations with interface #1689

Open
yav opened this issue Jun 26, 2024 · 0 comments
Open

Generalize instantiations with interface #1689

yav opened this issue Jun 26, 2024 · 0 comments
Labels
feature request Asking for new or improved functionality parameterized modules Related to Cryptol's parameterized modules

Comments

@yav
Copy link
Member

yav commented Jun 26, 2024

Cryptol allows "passing through" parameters like this:

module F where
  import interface I
  submodule M = G { interface I }

This means that when F is instantiated with some module A, M will be defined by instantiating G with the same M.

At present, I needs to always be a parameter to the current functor. It would make sense to generalize this to allow I be a parameter of an outer functor too, for example, like this:


module OuterF where
  import interface I
  submodule Inner where
    submodule M = G { interface I }

Note that in this case Inner is not a functor and has not parameters, but the definition of M still makes sense.

This should be fairly easy to implement, because at present the instantiation G { interface I } is implemented by desugaring to an anonymous module:

submodule M = G { interface I }
--->
submodule Anon where
   x = I::x
   ...

submodule M = G { Anon }

This exact same thing should work if I was a parameter to an outer functor too, so mostly we'd have to modify the code to look for the closest enclosing matching parameter.

@yav yav added feature request Asking for new or improved functionality parameterized modules Related to Cryptol's parameterized modules labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Asking for new or improved functionality parameterized modules Related to Cryptol's parameterized modules
Projects
None yet
Development

No branches or pull requests

1 participant