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

Importing instantiation of the parameterized module doesn't make those values available #1092

Closed
ajayeeralla opened this issue Feb 27, 2021 · 4 comments
Labels
importing instantiations parameterized modules Related to Cryptol's parameterized modules

Comments

@ajayeeralla
Copy link

//parameterized module
module M where
parameter
  x : [10]
type y = 10

//instantiated module
module N=M where
x = 20

// importing instantiated module
module O where
import N
// but I'm not able to access x value here for some reason
@ajayeeralla ajayeeralla added parameterized modules Related to Cryptol's parameterized modules importing instantiations labels Feb 27, 2021
@ajayeeralla ajayeeralla changed the title Importing instantiation of the parameterized module doesn't make the values available Importing instantiation of the parameterized module doesn't make those values available Feb 27, 2021
@weaversa
Copy link
Collaborator

weaversa commented Feb 27, 2021

Parameters are kept private. If you want to expose them, you can do something like this:

//parameterized module
module M where
parameter
  _x : [10]
type y = 10
x = _x

//instantiated module
module N=M where
_x = 20

// importing instantiated module
module O where
import N
// Now you can access x

@ajayeeralla
Copy link
Author

ajayeeralla commented Feb 27, 2021

Ah, I didn't know that parameters are private and the above example works. Thanks @weaversa.

I have another question:

module M where
type x = 10

module N where
import M 
type y = 20

module O where
import N
// but I'm not able to access x here but y only
// to access both x and y, I had import both M and N in this module

it seems to me that module importation isn't transitive?

@weaversa
Copy link
Collaborator

Yes, this helps keep the namespace under control.

@ajayeeralla
Copy link
Author

I see. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
importing instantiations parameterized modules Related to Cryptol's parameterized modules
Projects
None yet
Development

No branches or pull requests

2 participants