-
Notifications
You must be signed in to change notification settings - Fork 347
Proposal - Add haskell-process-wrapper-function #370
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
Conversation
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) | ||
(package-refresh-contents) | ||
(package-install 'el-mock)) | ||
|
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.
Beware this HACK here to install the el-mock dependencies...
How can we do better?
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.
Probably Cask would be the way to handle this robustly across the entire repo, because it has the concept of development dependencies.
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.
Yes, indeed.
I did not want to take it upon me to propose it (I already use it for org-trello).
So, shall I try and propose using Cask in this PR?
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.
Here we go #372 (in another PR to avoid cluttering this functionality).
As a side note, here is the possible project overload of emacs config (that @chrisdone suggested) about ((haskell-mode . ((haskell-process-wrapper . ("nix-shell" "haskell-lab.nix" "--command"))
(haskell-process-type . cabal-ghci)))) Cf. manual for interested readers. And thanks @chrisdone, I did not know this possibility. Cheers, |
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target.
Ok. So running cask with emacs-24.3 works but with emacs-snapshot fails. I'll revert those changes and propose another PR about Cask, this way the main functionality which works stays intact :D Cheers, |
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target.
66d101f
to
87cdc9b
Compare
87cdc9b
to
0fb902e
Compare
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target.
0fb902e
to
e838266
Compare
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target.
Rebased on latest master + squash all (intermediary) commits into 1. |
@ocharles Hello, as a fellow nixos user, can you please give this a try? |
This mostly looks good to me. One note would be that you're assuming the wrapped command will be passed to the wrapper as a single stringified argument. I'm not sure that would always be the case, because it would depend on the wrapper. If that's something we care about, then how about defining the wrapper via a (setq haskell-process-wrapper-function
(lambda (argv) (append '("nix-shell" "haskell-lab.nix" "--command")
(shell-quote-argument argv)))) Then you don't have to special-case the code where |
Yeah! Almost there :D (and this time, no over-complecting thing? :D)
Yes, I do! And yes, I'm not sure either. I did not how to test with other wrappers.
If I understood correctly, this is pretty neat! |
Yes, exactly, we wouldn't need |
Good. Note |
Ok. I'm working on it but I'm having a hard time unit testing this :D (flet, cl-letf, cl-flet, and whatnot for function binding in test context...). I'm pretty tired right now so I'll get back as soon as I have something. Cheers, |
Following this discussion - haskell#370 (comment). This permits to one's own wrapper function. For example, here is one to use with nix-shell: ```sh (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "default.nix" "--command" ) (list (shell-quote-argument (mapconcat 'identity argv " "))))))) ``` Unit tests are ok. Need to test in real life now.
Following this discussion - haskell#370 (comment). This permits to one's own wrapper function. For example, here is one to use with nix-shell: ```sh (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "default.nix" "--command" ) (list (shell-quote-argument (mapconcat 'identity argv " "))))))) ``` Unit tests are ok. Need to test in real life now.
Ok, so I got some more time and I could really test the following: |-----------------------------------------------+------+------------+------------+-----------|
| | ghci | cabal-repl | cabal-ghci | cabal-dev |
|-----------------------------------------------+------+------------+------------+-----------|
| Unit Tests | OK | OK | OK | OK |
|-----------------------------------------------+------+------------+------------+-----------|
| Manual without wrapper function (the default) | OK | OK | OK | N/A |
| Manual with wrapper function | OK | OK | OK | N/A |
|-----------------------------------------------+------+------------+------------+-----------| (as before I did not test cabal-dev because I do not know this one but I ensure the initial contract stays the same as before... in unit tests that is...) Here is the possible ((haskell-mode . ((haskell-process-wrapper-function . (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
(haskell-process-type . ghci)))) ;; ok
((haskell-mode . ((haskell-process-wrapper-function . (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
(haskell-process-type . cabal-repl)))) ;; ok
((haskell-mode . ((haskell-process-wrapper-function . (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
(haskell-process-type . cabal-ghci)))) ;; ok Their equivalence as (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
'(haskell-process-type ghci)) ;; ok
(custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
'(haskell-process-type cabal-repl)) ;; ok
(custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (mapconcat 'identity argv " ")))))
'(haskell-process-type cabal-ghci)) ;; ok Note Here is the sample that did not work out ((haskell-mode . ((haskell-process-wrapper-function . (lambda (argv) (append (list "nix-shell" "haskell-lab.nix" "--command" )
(list (shell-quote-argument (mapconcat 'identity argv " "))))))
(haskell-process-type . ghci)))) ;; shell-quote-argument does not work |
Following the discussion from haskell#350 (comment), creating a haskell-process-wrapper.
Following this discussion - haskell#370 (comment). This permits to one's own wrapper function. For example, here is one to use with nix-shell: ```sh (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "default.nix" "--command" ) (list (shell-quote-argument (mapconcat 'identity argv " "))))))) ``` Unit tests are ok. Need to test in real life now.
6a9d45a
to
bfc10c5
Compare
Rebased to the latest upstream/master. |
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target.
The implementation here looks good to me. Anyone else want to express an opinion, including re. the |
Ok - I can confirm it all works! I was able to load a file into |
Following the right procedure, I did not encounter any issue.
I tested like you (only the flag I remove).
Great news! Thanks! Cheers, |
I'm good to merge this. I tested it with my docker script with a (haskell-mode . ((haskell-process-type . ghci)
(haskell-process-wrapper-function
. (lambda (argv) (append (list "docker-run" "exec" "--")
argv))))) |
Any objections to merging? |
Not from me. |
Following this discussion - #370 (comment). This permits to one's own wrapper function. For example, here is one to use with nix-shell: ```sh (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "default.nix" "--command" ) (list (shell-quote-argument (mapconcat 'identity argv " "))))))) ``` Unit tests are ok. Need to test in real life now. Tests removed.
Following this discussion - #370 (comment). This permits to one's own wrapper function. For example, here is one to use with nix-shell: ```sh (custom-set-variables '(haskell-process-wrapper-function (lambda (argv) (append (list "nix-shell" "default.nix" "--command" ) (list (shell-quote-argument (mapconcat 'identity argv " "))))))) ``` Unit tests are ok. Need to test in real life now. Tests removed.
Merged as dcf4ad..44228b. Did not merge the Cask tests. They can be discussed in #372. Thanks, @ardumont! |
@chrisdone It would be great when you'll have some time to add in the |
@ardumont Right now I use an internal company tool for launching the docker, but if that changes I'll document it. =) |
Hi, could some one point me at an emacs config to get haskell mode working with nix-shell. I have tried setting haskell-process-wrapper-function but on a haskell-process-load-or-reload it never finds cabal when setting up the project. The project compiles & runs etc if i enter the shell myself with nix-shell --pure etc. Thanks |
@fatlazycat does none of those work? |
It was broken for me as well until 35633bf, maybe that fixed it for you. |
Ok, indeed, without this code, that would not work :D |
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. *Beware* emacs-23 is not supported by Cask.
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. *Beware* emacs-23 is not supported by Cask.
Hello,
Following this PR and its possible improvment, I added the
haskell-process-wrapper
.This permits to launch the
haskell-process-type
command (insidehaskell-process-start
function) inside a wrapper command (nix-shell
for example, or others).For example, using this:
For this example, this triggers the
cabal repl
command insidenix-shell
(defined within the default.nix expression).I tested manually - ardumont@3f6e21d with:
haskell-process-wrapper
(for nix-shell as above) withhaskell-process-type
in(cabal-repl cabal-ghci ghci)
.haskell-process-wrapper
nil (the default) andhaskell-process-type
in
(cabal-repl cabal-ghci ghci)
.The code is generic, so this should work for the other commands that @chrisdone mentioned.
Note
I added unit tests (to enforce that I did not break anything) and I needed mocks (I added the deps inside the
haskell-process-tests.el
file but this must not be what you want.If you have any suggestions on how to improve this, I'm all for it.