-
Notifications
You must be signed in to change notification settings - Fork 121
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
Lean: add placeholder for state monad to stateful functions #870
Conversation
How do you plan to translate a function body like this?
I don't get how the idea of returning a pair of string works. |
Something like do
let x ← rX 0
if x then do
wX 0 3
return 11
else do
return 0 Only when This PR does not make all expression constructor ready for this. I just thought we'd might get it merged since the work that remains will be a major overhaul of |
Note that if you're using the usual rewrites, the Sail AST will already be in monadic form, with the monadic bind begin |
I think there is a typo in the commit/PR titles placehodler -> placeholder |
@bacam In the end I want to be able to translate ... do
return f (← g x) if |
OTOH maybe that's a cosmetic thing that can be done afterwards |
You could have a different version of that rewrite that leaves arguments like |
Adds a monad
StateM
which is added to all stateful functions. In the body of stateful function definitions, we put everything inside areturn
statement, but the idea is that in the future,doc_exp
will return a pair of strings, one for thedo
block and one print of the pure part of the expression which goes into thereturn
call