Skip to content

Pr add haskell compiler type #1717

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

Merged
merged 2 commits into from
Sep 15, 2020

Conversation

mberkowitz
Copy link
Contributor

Have haskell-compile choose a build tool (stack, cabal, ghc) the same way that
haskell-interactive mode chooses a repl (stack repl, cabal repl, ghci).

That is, add a new customization variable haskell-compiler-type analogous to
haskell-process-type. It's an enum with values to select stack, cabal, or ghc;
and the value 'auto tells emacs to find the closest stack.yaml or *.cabal file
to decide.

Also drops the value 'cabal-new-repl for haskell-process-type, since cabal now
defaults to the new (v2) behavior. I did not add a way to choose cabal v1.

The same code (factored out as (haskell-build-type)) is used for compiler and
repl. It does a rough guess, which is good enough since the chosen command can
be previewed and edited.

haskell-compiler-type replaces the bool haskell-compile-ignore-cabal, which
was biased against stack, and inconsistent with haskell-interactive-mode.

Why two variables instead of one? I can't imagine wanting to compile and
interact with different tools, but I didn't want to make haskell-compile
depend on haskell-interactive-mode, since a user may prefer a different emacs
library instead of either of them.

This pull request is similar in intent to the long-pending #1545,
but is based on a more recent haskell-compile.

Copy link
Member

@purcell purcell left a comment

Choose a reason for hiding this comment

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

Mostly looks great afaict, and I'm inclined towards merging this relatively aggressively, but see my notes about removal of the cabal-new-repl option and potential breakage for users.

…ler-type,

which is similar to haskell-process-type. This makes haskell-compile
choose build tools the same way haskell-interactive-mode does.

Values are 'cabal, 'cabal-project, 'stack, or 'ghc to choose a build tool,
or 'auto (default) to look for stack or cabal files.

For haskell-process-type the corresponding values remain 'cabal-repl,
'cabal-new-repl, 'stack-repl, 'ghci.

In fact 'cabal-new-repl is obsolete and is accepted as a setting of the
defcustom, with a warning, but the accessor function (haskell-process-type)
returns 'cabal-repl instead.

Factors out logic that deals with value 'auto for both of these, as
(haskell-build-type). Also removes a bit of duplicated code from
(haskell-process-do-cabal) in haskell-load.el.
@mberkowitz mberkowitz marked this pull request as draft September 15, 2020 00:11
@mberkowitz mberkowitz changed the title Pr add haskell compiler type (WIP) Pr add haskell compiler type Sep 15, 2020
Don't reuse cabal or stack command when project dir has changed.

When haskell-compiler-type is stack or cabal, and no stack or cabal file was
found, run in default-directory. Stack or cabal will fail with appropriate
error.
@mberkowitz mberkowitz force-pushed the pr-add-haskell-compiler-type branch from 79b033c to 63cc0fd Compare September 15, 2020 03:33
@mberkowitz mberkowitz changed the title (WIP) Pr add haskell compiler type Pr add haskell compiler type Sep 15, 2020
@mberkowitz mberkowitz marked this pull request as ready for review September 15, 2020 03:39
@mberkowitz
Copy link
Contributor Author

Please review again.
Rewritten to allow obsolete value haskell-process-type = 'cabal-new-repl,
converted to the equivalent value 'cabal-repl (with a warning) on 1st use.
Also fixed a couple of bugs found hand-testing haskell-compiler-type.
I don't understand the CI test results on my branch. When I test by hand (make check), I see 3 errors in files I haven't changed:
Ran 539 tests, 536 results as expected, 1 unexpected, 2 skipped (2020-09-14 20:32:36-0700, 17.627873 sec)
121 expected failures

1 unexpected results:
FAILED haskell-indent-put-region-in-literate-2

2 skipped results:
SKIPPED haskell-indent-in-comment-1
SKIPPED haskell-indentation-altj-comment

@purcell
Copy link
Member

purcell commented Sep 15, 2020

The CI results are spurious, sorry: fixed in a71bc2b.

This all looks good to me, so I'll go ahead and merge, and if any related issues come up here then I'll tag you in and we can figure them out together. Thanks again!

@purcell purcell merged commit 4cc375d into haskell:master Sep 15, 2020
@mberkowitz
Copy link
Contributor Author

mberkowitz commented Sep 16, 2020 via email

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

Successfully merging this pull request may close these issues.

2 participants