Implement "Rethinking REPLs"#248
Conversation
|
I'm happy to clean up the lint if you like the idea. Also, I just realized that maybe |
|
@jkeuhlen made the good point that this can let people run arbitrary code. It should probably be hidden behind a flag :) |
ndmitchell
left a comment
There was a problem hiding this comment.
Thanks, a bunch of comments, but fundamentally seems like a good feature to include, so happy to see it go in.
src/Ghcid.hs
Outdated
|
|
||
| let outputFill :: String -> Maybe (Int, [Load]) -> [String] -> IO () | ||
| outputFill currTime load msg = do | ||
| let outputFill :: String -> Maybe (Int, [Load]) -> [((FilePath, (Int, Int)), (String, String))] -> [String] -> IO () |
There was a problem hiding this comment.
If we had a separate EvalResult type (which seems like a good idea anyway) then this bit type argument would have that type, which would be good.
|
Excited to hear that you like the idea! In addition to (or instead of) the I'll clean up the lint today. |
|
@ndmitchell waiting for some guidance on this before going further --- in particular around whether |
ndmitchell
left a comment
There was a problem hiding this comment.
- I don't think there's any need for a ReaderT - I think doing what you've already done, but slightly hiding some details so we are free to change them in future, is probably sufficient.
- I do think EvalResult should be split off as a separate type, to keep the library version coherent and self-contained.
- My inclination is to just run all eval snippets. If someone wants to maliciously take over your computer then TemplateHaskell is a much easier and more reliable vector that works whether you cabal install, ghci or ghcid. I can't imagine anyone is going to go for a more complex method that only works with newer versions of ghcid.
src/Session.hs
Outdated
| -- Not suitable for calling multithreaded. | ||
| module Session( | ||
| Session, withSession, | ||
| Session(allowEval), withSession, |
There was a problem hiding this comment.
I was thinking of keeping allowEval in Session, but not exposing the allowEval (which gives you a lot of power), and instead just enableEval s = s{allowEval=True}. That way Session remains entirely abstract, but you can keep the rest of the code the same, without any ReaderT or similar.
|
Sounds great! I'll try to get this polished up tomorrow. |
|
@ndmitchell I think I've responded to all of your suggestions. CI is broken, but it appears to be for unrelated reasons: |
|
@isovector thank you for this feature! Just tried it and had only one minor inconvenience with language pragmas not affecting the ghcid repl. results in but is fine if I add I guess it could be fixed by not only collecting lines starting with |
|
@ethercrow yeah, I've been running into that too. There's also an issue with the imports being in the wrong scope. Perhaps @ndmitchell has some ideas about doing this more correctly. |
|
Gentle ping on this. |
|
Sorry, Zurihac burnt out all my brain cycles for a few days and I'm still in catch up. I'll do a real review tomorrow (when my brain has returned) |
|
Thanks, took a few more days for my brain to recover, but it looks all good. Could I trouble you to write a paragraph or so for the README, explaining what the feature is and roughly how to use it? Otherwise its unlikely to be discoverable for users. |
|
|
This PR implements the Unison notebook idea --- essentially adding support for interactive REPL commands directly in source code.
The idea is that I can write the following:
to which, ghcid will now reply:
In essence, this lets you run little repl commands directly in your source file.
Link to the original idea in Unison: unisonweb/unison#252