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

Define default directory for haskell-stack-ghc checker #1007

Merged
merged 4 commits into from
Jul 12, 2016
Merged

Define default directory for haskell-stack-ghc checker #1007

merged 4 commits into from
Jul 12, 2016

Conversation

sergv
Copy link
Contributor

@sergv sergv commented Jul 9, 2016

Default directory is detected either by looking for stack.yaml or asking stack path --project-root for haskel-stack-ghc checker or by looking for cabal file in case of haskell-ghc checker.

@mrkkrp Please comment, if you think something should be done differently.

@@ -6976,6 +6976,36 @@ Otherwise return the previously used cache directory."
(or flycheck-haskell-ghc-cache-directory
(make-temp-file "flycheck-haskell-ghc-cache" 'directory))))

(defun flycheck-haskell--default-directory (checker)
"Come up with a sutable default directory for Haskell to run checker in."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come up sounds strange. Why not simply "find"?

Please also extend the docstring to explain what a "suitable" directory would be, i.e. document the behaviour of the function as well.

(replace-regexp-in-string
(rx (* (any " \t\n")) eos)
""
(shell-command-to-string "stack path --project-root"))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use process-lines instead of shell-command-to-string. We should not use shell commands without need.

@swsnr
Copy link
Contributor

swsnr commented Jul 10, 2016

Thanks. I've done a cursory review, will look at the details tomorrow.

@swsnr
Copy link
Contributor

swsnr commented Jul 10, 2016

@flycheck/haskell @purcell Would you also take a look? Maybe also test this PR on different Haskell projects?

@sergv
Copy link
Contributor Author

sergv commented Jul 10, 2016

@lunaryorn I've amended commit with your suggestions.

@mrkkrp
Copy link
Contributor

mrkkrp commented Jul 10, 2016

@sergv, Looks good, thank you for writing this! I'm looking forward to using it.

@purcell
Copy link
Member

purcell commented Jul 11, 2016

LGTM. I tried this patch on top of flycheck HEAD with a fairly vanilla stack project and all was well, so I'm pretty confident this will work.

@@ -6976,6 +6976,45 @@ Otherwise return the previously used cache directory."
(or flycheck-haskell-ghc-cache-directory
(make-temp-file "flycheck-haskell-ghc-cache" 'directory))))

(defun flycheck-haskell--find-default-directory (checker)
"Come up with a sutable default directory for Haskell to run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sutablesuitable

@cpitclaudel
Copy link
Member

I've added quick review notes as well. Thanks for this PR!

@cpitclaudel
Copy link
Member

@purcell Thanks for the review-of-the-review :))

@sergv
Copy link
Contributor Author

sergv commented Jul 11, 2016

@cpitclaudel I've rebased on master and added commit that fixes review notes

(process-lines "stack" "path" "--project-root"))
(stack-dir
(when stack-output
(car stack-output))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergv The when guard is redundant. (car nil) is perfectly safe and evaluates to nil so it's perfectly safe to just do (car (process-lines …)).

@swsnr
Copy link
Contributor

swsnr commented Jul 11, 2016

@sergv Would you add a note about this change to CHANGES.rst? I think it falls under Improvements: 😊

@swsnr
Copy link
Contributor

swsnr commented Jul 12, 2016

LGTM. Thanks for the change 😊

I think though that #1012 should go in first.

@sergv sergv merged commit fa035f0 into flycheck:master Jul 12, 2016
@sergv sergv deleted the stack-ghc-checker-default-directory branch July 12, 2016 07:59
swsnr added a commit that referenced this pull request Jul 12, 2016
@swsnr
Copy link
Contributor

swsnr commented Jul 12, 2016

@sergv I think you forgot to rename :default-directory to :working-directory here before merging this PR. I fixed it in ceaf8c4. Could take another look?

@sergv
Copy link
Contributor Author

sergv commented Jul 12, 2016

@lunaryorn Indeed, I missed it. Thank you!

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

Successfully merging this pull request may close these issues.

None yet

5 participants