ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.14k stars 113 forks source link

drop into repl after successful loading #250

Open adrian-gierakowski opened 5 years ago

adrian-gierakowski commented 5 years ago

is it possible to drop into interactive repl session after successful loading/reloading?

thanks!

ndmitchell commented 5 years ago

Nope, and it would be hard to do since ghcid assumes it has complete control over the session, so has done crazy things like giving it a weird prompt etc. It's not completely infeasible, since ghcid could give you its own session and proxy them on, but its not in the plans.

adrian-gierakowski commented 5 years ago

Thank you for explanation.

When you say "its not in the plans" is it because you don't think it would be useful, or because you'd rather focus hour efforts somewhere else? If the latter, would you accept a PR implementing it?

ndmitchell commented 5 years ago

My focus is elsewhere, I think it could be quite a significant piece of work, I think there are a lot of trade offs, and I'm not convinced the end result will be that nice. That said, if you make a PR, the PR doesn't overly complicate stuff, and it works reasonably enough, I'm happy - it is something quite a lot of people ask for.

That said, I do wonder if something that reloads would be better integrated into ghci itself, since you are taking the prompt bits from ghci and the reloading from ghcid - and the combination involves much more ghci.

freckletonj commented 4 years ago

Glad I found this issue, I totally thought ghcid was a repl enhancement, and was pulling my hair out trying to solve why it was broken.

"GHCi as a daemon" or "GHC + a bit of an IDE". it opens ghci and runs :reload

So ghcid basically just compiles your code to give you ghc's error output, only, it does so automatically, and actually interpreting is faster to do than compiling, so it does that instead.

freckletonj commented 4 years ago

One more thing I just discovered surfing the issues, is the flag --allow-eval.

ndmitchell commented 4 years ago

Thanks for letting me know @freckletonj - it's not an unreasonable confusion - I've updated the README to say you can't use the ghci it spawns: https://github.com/ndmitchell/ghcid/blob/master/README.md. There is an active ticket for documenting --allow-eval.

docteurklein commented 4 years ago

my 2 cents on this topic: you can use inotifywait in conjunction with tmux to automate pretty much anything and emulate a part of what ghcid does:

inotifywait -e create -e close_write -rm src | xargs -L1 -I{} \
    tmux send-keys -R -t 1.2 :r enter

would clear the repl (-R) and reload the sources (:r enter) everytime something changed in the src folder.

You first need to run your repl in a tmux pane (in my example located at 1.2).

Hope it helps :)

adrian-gierakowski commented 4 years ago

@docteurklein thanks for the tip!