-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add runStmt
for executing IO statements and binding new names
#38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Apologies for the late reply; I was travelling when this came through.
I'm not sure that I understand the purpose of this addition. Could you not accomplish the same with the existing API?
CC @gelisam
CHANGELOG.md
Outdated
### 0.7.1 | ||
|
||
* Add `runStmt` for executing statements in the `IO` monad and binding new names. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't mention a new release. We don't know if it will be 0.7.1 or 0.8.0, for example.
If you want to start the new changelog entry, call it "Upcoming release".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Sorry about this, I just wanted to reduce your burden of having to update numbers everywhere, but was apparently overly eager.
hint.cabal
Outdated
@@ -1,5 +1,5 @@ | |||
name: hint | |||
version: 0.7.0 | |||
version: 0.7.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change this.
8493df3
to
87cec5c
Compare
No worries. 😄
No, I don't think so. The thing is that IO actions that are executed with |
Close, but not quite. If the host program knows the type of the variables which get bound by those statements, it's possible to construct an environment on the host program's side, and to pass this environment to every subsequent expression and statement as follows.
But if the statements are arbitrary strings typed by the user, the host program can't know what type they have, and so the variables can't be transferred from the interpreted program to the host program. As a result, the host program can't put those values back into scope when evaluating the next expression. With If it was only up to me, however, I would expose the feature in a slightly more structured way.
I wouldn't provide anything special for expressions and IO actions whose type has a Show instance, it's easy enough to implement those today using the normal |
Strictly speaking,
will bind values to both If only
Note that we have to pay attention that the intermediate variable
that generates a new unique variable name within a single interpreter session. (Of course, the library user could implement this him/herself, but in this case, I think it is justified to have it as part of the library, because dealing with variables and shadowing is something that interpreter libraries should do.) |
+1 for The use case in which a pattern is used to bind multiple variables at once looks tricky to implement in terms of |
6cd881b
to
6313092
Compare
Any decision on this? I'm happy to draw up another pull request that implements (I have added proper support for GHC 8.2, where the old |
Thanks for fixing the GHC 8.2 support. @gelisam seems to understand this well, so I'll let him decide. He's a collaborator, so he can press the "rebase and merge" button if he wishes, or request changes. |
6313092
to
6f0d544
Compare
I can? I have noticed that you're a lot more conservative than I am when it comes to merging patches, so you might regret this :) Rebased and merged! |
I'm simply conservative because I don't know as much Haskell/GHC as others and because I default to not extending the API :) Thanks for your help! |
Hello Daniel, thanks for maintaining
hint
!My project HyperHaskell is built on the
hint
library. In order to be as useful as the command line GHCi, I need the ability to bind names and execute statements in theIO
monad, e.g. the ability to interpret things likeFor this reason, I have implemented a wrapper around the
runStmt
function from the GHC API, and would like to see it included in thehint
library, hence this pull request.