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

Feature request: support REPLish workflow #35

Open
ethercrow opened this issue Jul 30, 2018 · 4 comments
Open

Feature request: support REPLish workflow #35

ethercrow opened this issue Jul 30, 2018 · 4 comments
Labels

Comments

@ethercrow
Copy link

I wonder if a typical ghci workflow can be automated with sos.

Usually you run a ghci process and:

  1. When *.hs changes, you send :r<CR> or possibly :r<CR>:main<CR> to ghci
  2. When *.cabal or *.yaml changes, you restart ghci
  3. Also you're able to type stuff into currently running ghci

Right now 2. is working perfectly, 3. works kind of weird (I'm not even sure how to describe it) and 1. is not covered at all.

Meanwhile, ghcid supports 1 and 2, but not 3 (by current design) and naturally only supports ghci. Ideally I'd like to be able to use sos to automate a REPL workflow for any language, e.g. restart the process on project.clj changes and send (run-all-tests)<CR> on other changes.

@schell
Copy link
Owner

schell commented Jul 30, 2018

This is a good idea.

@schell schell added the feature label Jul 30, 2018
@jappeace
Copy link

jappeace commented Mar 6, 2019

Instead of focusing on making a repl work, how about making any shell work (since a repl is just a shell).
I want something similar but execute stuff in a nix shell instead.

Something like:

commands: 
   - shell: ghci
     command: :r 
     invalidate: *.yaml *.cabal
   - shell: nix-shell
     command: cabal new-build -j --ghc-options --no-code
     invalidate: *.nix

@schell
Copy link
Owner

schell commented Mar 7, 2019

Oh wow that's a great idea! I could use that at work.

@jappeace
Copy link

jappeace commented Mar 8, 2019

I've been thinking about this, but getting this to work in just native Haskell maybe hard.
What you want is having the shell running in the background and then be able to write input to it and intercept the output.

Now the output isn't hard as it's just a stdout file handle. But the input is more problematic, see:
https://serverfault.com/questions/178457/can-i-send-some-text-to-the-stdin-of-an-active-process-running-in-a-screen-sessi/547144
You can write to the stdin, but it bypasses the program. In other words, the shell doesn't process the command send to stdin.

The solutions offered are either the screen command, or use tmux, for which a client exists: http://hackage.haskell.org/package/chiasma.
In any case it would depend on external programs.

Maybe tmux is the right approach as this project shouldn't be doing shell management itself?

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants