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

Use reader-monad bracketing combinators for extending bound variable environment in translator #1254

Closed
brianhuffman opened this issue Dec 2, 2020 · 1 comment
Assignees
Labels
subsystem: saw-core-coq Issues related to converting saw-core to Gallina for use with the Coq/Rocq theorem prover tech debt Issues that document or involve technical debt

Comments

@brianhuffman
Copy link
Contributor

Currently the term translation monad is just a state monad, and the local variable environment is just one of the fields in the mutable monad state, which can be updated at any time. As @eddywestbrook suggests in the comment thread of GaloisInc/saw-core-coq#29, it would be more principled to use reader-monad-style operations to manage the local variable environment. Following this discipline will make the code easier to understand and make errors easier to avoid.

So instead of

translateAndBindName :: String -> m Ident

we should use only bracketing combinators like

withTranslatedName :: String -> (Ident -> m a) -> m a

that explicitly delimit the scope of the Ident that is added to the local environment.

@brianhuffman brianhuffman transferred this issue from GaloisInc/saw-core-coq Jan 21, 2021
@brianhuffman brianhuffman transferred this issue from GaloisInc/saw-core Apr 27, 2021
@brianhuffman brianhuffman added subsystem: saw-core-coq Issues related to converting saw-core to Gallina for use with the Coq/Rocq theorem prover tech debt Issues that document or involve technical debt labels Apr 27, 2021
@eddywestbrook
Copy link
Contributor

Closed by #1928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: saw-core-coq Issues related to converting saw-core to Gallina for use with the Coq/Rocq theorem prover tech debt Issues that document or involve technical debt
Projects
None yet
Development

No branches or pull requests

3 participants