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

Blocking dependency on ghc-mod #350

Closed
orome opened this issue Nov 25, 2017 · 29 comments
Closed

Blocking dependency on ghc-mod #350

orome opened this issue Nov 25, 2017 · 29 comments

Comments

@orome
Copy link

orome commented Nov 25, 2017

I may have this wrong, but it appears there's no way to use this with recent GHC, because ghc-mod doesn't work with GHC 8.2.2 (DanielG/ghc-mod#900).

Is there a way to get an ghc-mod executable that works with GHC 8.2.2?

@bgamari
Copy link

bgamari commented Dec 5, 2017

Not currently I'm afraid. Help on DanielG/ghc-mod#900 would be appreciated though.

@orome
Copy link
Author

orome commented Dec 5, 2017

@bgamari What do you recommend for folks who are using GHC 8.2.X? Should we disable/remove ghc-mod?

@orome
Copy link
Author

orome commented Jul 26, 2018

Any news on this?

@carymrobbins
Copy link
Owner

@orome Sadly I don't think so. I'd track that ghc-mod ticket for progress, but currently, there doesn't appear to be any.

@orome
Copy link
Author

orome commented Jul 26, 2018

@carymrobbins Will do. Thx.

@orome
Copy link
Author

orome commented Oct 20, 2018

Just to confirm that I understand the error I'm seeing. Is the issue that the GHC used to compile ghc-mod doesn't match the GHC that's set as the one used as the "Haskell Compiler" in the IDE? If so, why do these need to match at all? Shouldn't it be possible to lint/format the code using executables compiled with arbitrary GHC?

I ask because it seems like one way around this would simply be not to care what GHC has been specified elsewhere or is being used globally on the command line (if that's were the incompatibility arises), or to provide an additional setting to point to a matching GHC (e.g. off the path somewhere).

(And for that matter, if I'm building with stack, why is the "Haskell Compiler" setting for GHC relevant at all: I could be using any GHC, as specified in my stack.yaml?)

@carymrobbins
Copy link
Owner

carymrobbins commented Oct 23, 2018

Shouldn't it be possible to lint/format the code using executables compiled with arbitrary GHC?

Yes, that part is possible and doesn't need ghc-mod, you can do that with hlint and/or your formatter directly.

Also, I just recently discovered that there are working ghc-mod builds for GHC >= 8.2 available in this fork - https://github.com/alanz/ghc-mod/tree/ghc-8.4-hie

I'm currently using the GHC 8.4 build and it seems to be working pretty well.

@orome
Copy link
Author

orome commented Oct 24, 2018

I don't see any linting or formatting inspections at all. How can I confirm that it's working? (I do get some auto-completion though). I have no entry for ghc-mod or ghc-modi, since that's not compatible, but have the other tools configured.

@carymrobbins
Copy link
Owner

@orome Check the Haskell Tools Console. It should show you the output for your configured tools.

image

If you don't see it, it might have to do with the checking for Haskell modules and the way you created the project. If you are using stack and imported the project using HaskForce's stack project import wizard, it should "just work". Otherwise, you might need to explicitly import the module as a Haskell Module from the Project Structure menu. Ideally though it could better detect that you have tools configured, so it should just show the console regardless.

@carymrobbins
Copy link
Owner

@orome Just to double check, you do have hlint configured in the Haskell Tools, correct?

@orome
Copy link
Author

orome commented Oct 24, 2018

Yes. It's setup there. I see hlint output on the Haskell Tools Console, but I don't see any inspections or highlighting in the IDE editor window.

My package is listed under modules in the Project Structure. Are there other setting there that need to be just so (e.g., I don't have a project SDK configured, just Haskell as a module SDK, whatever that means).

@carymrobbins
Copy link
Owner

@orome Do you see the Haskell Tools Console at the bottom of your IDE?

@orome
Copy link
Author

orome commented Oct 24, 2018

Yes.

@carymrobbins
Copy link
Owner

Ok, so then do you see the output from hlint there?

@orome
Copy link
Author

orome commented Oct 24, 2018

Yes, see above. But I see nothing in the IDE editor window. Should I?

@carymrobbins
Copy link
Owner

That seems strange. Maybe copy/paste the output you see from hlint into a gist and link here?

@orome
Copy link
Author

orome commented Oct 25, 2018

I get, for example:

Using working directory: /Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/.idea
/Users/Rax/.local/bin/hlint --no-exit-code --version
Using working directory: /Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/.idea
/Users/Rax/.local/bin/hlint --no-exit-code /Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs --json
[{"module":["Crypto.Enigma"],"decl":["stages"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":238,"startColumn":17,"endLine":238,"endColumn":43,"from":"(length $ components ec) - 1","to":"length (components ec) - 1","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 238, startCol = 17, endLine = 238, endCol = 41}, subts = [(\"a\",SrcSpan {startLine = 238, startCol = 18, endLine = 238, endCol = 24}),(\"b\",SrcSpan {startLine = 238, startCol = 27, endLine = 238, endCol = 40})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":["step"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":275,"startColumn":29,"endLine":275,"endColumn":70,"from":"(mod (positions ec !! i + di - 1) 26) + 1","to":"mod (positions ec !! i + di - 1) 26 + 1","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 275, startCol = 29, endLine = 275, endCol = 66}, subts = [(\"x\",SrcSpan {startLine = 275, startCol = 30, endLine = 275, endCol = 65})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["windows"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":296,"startColumn":36,"endLine":296,"endColumn":67,"from":"windowLetter ec <$> (stages ec)","to":"windowLetter ec <$> stages ec","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 296, startCol = 56, endLine = 296, endCol = 67}, subts = [(\"x\",SrcSpan {startLine = 296, startCol = 57, endLine = 296, endCol = 66})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":324,"startColumn":23,"endLine":324,"endColumn":47,"from":"(== (length components'))","to":"(== length components')","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 324, startCol = 26, endLine = 324, endCol = 46}, subts = [(\"x\",SrcSpan {startLine = 324, startCol = 27, endLine = 324, endCol = 45})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":328,"startColumn":25,"endLine":330,"endColumn":67,"from":"(and $ (== 2) . length <$> splitOn \".\" plug) &&\n  (and $ (`elem` letters) <$> filter (/= '.') plug) &&\n    ((\\ s -> s == nub s) $ filter (/= '.') plug)","to":"and ((== 2) . length <$> splitOn \".\" plug) &&\n  (and $ (`elem` letters) <$> filter (/= '.') plug) &&\n    ((\\ s -> s == nub s) $ filter (/= '.') plug)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 328, startCol = 25, endLine = 328, endCol = 66}, subts = [(\"a\",SrcSpan {startLine = 328, startCol = 26, endLine = 328, endCol = 29}),(\"b\",SrcSpan {startLine = 328, startCol = 32, endLine = 328, endCol = 65})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":329,"startColumn":25,"endLine":330,"endColumn":67,"from":"(and $ (`elem` letters) <$> filter (/= '.') plug) &&\n  ((\\ s -> s == nub s) $ filter (/= '.') plug)","to":"(and $ (`elem` letters) <$> filter (/= '.') plug) &&\n  (\\ s -> s == nub s) (filter (/= '.') plug)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 330, startCol = 25, endLine = 330, endCol = 67}, subts = [(\"a\",SrcSpan {startLine = 330, startCol = 26, endLine = 330, endCol = 44}),(\"b\",SrcSpan {startLine = 330, startCol = 47, endLine = 330, endCol = 66})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":329,"startColumn":25,"endLine":330,"endColumn":67,"from":"(and $ (`elem` letters) <$> filter (/= '.') plug) &&\n  ((\\ s -> s == nub s) $ filter (/= '.') plug)","to":"and ((`elem` letters) <$> filter (/= '.') plug) &&\n  ((\\ s -> s == nub s) $ filter (/= '.') plug)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 329, startCol = 25, endLine = 329, endCol = 73}, subts = [(\"a\",SrcSpan {startLine = 329, startCol = 26, endLine = 329, endCol = 29}),(\"b\",SrcSpan {startLine = 329, startCol = 32, endLine = 329, endCol = 72})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":335,"startColumn":46,"endLine":335,"endColumn":76,"from":"(mod (numA0 w - r + 1) 26) + 1","to":"mod (numA0 w - r + 1) 26 + 1","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 335, startCol = 46, endLine = 335, endCol = 72}, subts = [(\"x\",SrcSpan {startLine = 335, startCol = 47, endLine = 335, endCol = 71})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Error","hint":"Redundant $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":341,"startColumn":17,"endLine":341,"endColumn":85,"from":"reverse $\n  (read <$> (splitOn \".\" $ \"01.\" ++ rngs ++ \".01\") :: [Int])","to":"reverse (read <$> (splitOn \".\" $ \"01.\" ++ rngs ++ \".01\") :: [Int])","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 341, startCol = 17, endLine = 341, endCol = 85}, subts = [(\"a\",SrcSpan {startLine = 341, startCol = 17, endLine = 341, endCol = 24}),(\"b\",SrcSpan {startLine = 341, startCol = 27, endLine = 341, endCol = 85})], orig = \"a b\"}]"}
,{"module":["Crypto.Enigma"],"decl":["configEnigmaExcept"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":341,"startColumn":28,"endLine":341,"endColumn":75,"from":"read <$> (splitOn \".\" $ \"01.\" ++ rngs ++ \".01\")","to":"read <$> splitOn \".\" (\"01.\" ++ rngs ++ \".01\")","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 341, startCol = 37, endLine = 341, endCol = 75}, subts = [(\"a\",SrcSpan {startLine = 341, startCol = 38, endLine = 341, endCol = 49}),(\"b\",SrcSpan {startLine = 341, startCol = 52, endLine = 341, endCol = 74})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":[],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":383,"startColumn":66,"endLine":383,"endColumn":96,"from":"(printf \"%02d\") <$> (rings ec)","to":"printf \"%02d\" <$> (rings ec)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 383, startCol = 66, endLine = 383, endCol = 81}, subts = [(\"x\",SrcSpan {startLine = 383, startCol = 67, endLine = 383, endCol = 80})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":[],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":383,"startColumn":66,"endLine":383,"endColumn":96,"from":"(printf \"%02d\") <$> (rings ec)","to":"(printf \"%02d\") <$> rings ec","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 383, startCol = 86, endLine = 383, endCol = 96}, subts = [(\"x\",SrcSpan {startLine = 383, startCol = 87, endLine = 383, endCol = 95})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["componentMapping"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":435,"startColumn":28,"endLine":435,"endColumn":62,"from":"rotMap (1 - p) letters !! (numA0 ch)","to":"rotMap (1 - p) letters !! numA0 ch","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 435, startCol = 52, endLine = 435, endCol = 62}, subts = [(\"x\",SrcSpan {startLine = 435, startCol = 53, endLine = 435, endCol = 61})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["componentMapping"],"severity":"Suggestion","hint":"Move brackets to avoid $","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":436,"startColumn":16,"endLine":436,"endColumn":63,"from":"chrA0 <$> (ordering $ componentMapping Fwd c p)","to":"chrA0 <$> ordering (componentMapping Fwd c p)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 436, startCol = 26, endLine = 436, endCol = 63}, subts = [(\"a\",SrcSpan {startLine = 436, startCol = 27, endLine = 436, endCol = 35}),(\"b\",SrcSpan {startLine = 436, startCol = 38, endLine = 436, endCol = 62})], orig = \"a (b)\"}]"}
,{"module":["Crypto.Enigma"],"decl":["componentMapping"],"severity":"Warning","hint":"Eta reduce","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":439,"startColumn":9,"endLine":439,"endColumn":59,"from":"rotMap o w = take 26 . drop (mod o 26) . cycle $ w","to":"rotMap o = take 26 . drop (mod o 26) . cycle","note":[],"refactorings":"[]"}
,{"module":["Crypto.Enigma"],"decl":["stageMappingList"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":473,"startColumn":23,"endLine":473,"endColumn":47,"from":"((stageMapping Fwd) <$>)","to":"(stageMapping Fwd <$>)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 473, startCol = 24, endLine = 473, endCol = 42}, subts = [(\"x\",SrcSpan {startLine = 473, startCol = 25, endLine = 473, endCol = 41})], orig = \"x\"}]"}
,{"module":["Crypto.Enigma"],"decl":["stageMappingList"],"severity":"Suggestion","hint":"Redundant bracket","file":"/Users/Rax/Documents/Projects/Coding/Haskell/crypto-enigma/Crypto/Enigma.hs","startLine":473,"startColumn":51,"endLine":473,"endColumn":75,"from":"((stageMapping Rev) <$>)","to":"(stageMapping Rev <$>)","note":[],"refactorings":"[Replace {rtype = Expr, pos = SrcSpan {startLine = 473, startCol = 52, endLine = 473, endCol = 70}, subts = [(\"x\",SrcSpan {startLine = 473, startCol = 53, endLine = 473, endCol = 69})], orig = \"x\"}]"}]

And this changes as expected in response to annotations or specs in .hlint.yaml — but nothing in the IDE editor window.

@carymrobbins
Copy link
Owner

And I assume you are looking for lint warnings in crypto-enigma/Crypto/Enigma.hs ? If so, maybe open up the IntelliJ log (Help > Show Log) and look for log entries or stack traces with haskforce in them.

% grep -i haskforce /Users/Rax/Library/Logs/IntelliJIdea2018.2/idea.log

@orome
Copy link
Author

orome commented Oct 26, 2018

Here's what the command above produces.

@carymrobbins
Copy link
Owner

@orome Ah ok, I think that's a bug introduced by hlint >= 2.1.5 where the JSON format changed. I have fixed it in commit 9a8612e; however, I haven't released it. I have a few bug fixes that are probably ready to be released as well as an experimental auto-import feature, so I'll get those packaged up and released in the next couple of days.

In the meantime, you can probably build HaskForce from source, which is pretty straight forward.

@orome
Copy link
Author

orome commented Oct 26, 2018

Is there any way to also add a feature that allows picking a GHC to use with the executables (ghc-mod, etc.)? As it now stands this GHC has to be (I think) the system GHC (or is it the project GHC), which means that if that's been updated beyond 8.0.2, ghc-mod can't be used.

@carymrobbins
Copy link
Owner

If you are using stack, it should use your resolver's ghc. Otherwise, ghc is configurable under

Project Preferences > Build, Execution, Deployment > Compiler > Haskell Compiler

@orome
Copy link
Author

orome commented Oct 26, 2018

Exactly; and those affect my builds, meaning that I'd have to limit them to 8.0.2 just to use ghc-mod. Shouldn't it be possible for Haskforce to use its own GHC, independent of the one used to build the project?

@carymrobbins
Copy link
Owner

The GHC version of ghc-mod has to match your project, otherwise it won't work.

@orome
Copy link
Author

orome commented Oct 26, 2018

Ah, so ghc-mod can't be used with any project built for GHC>8.0.2 then.

@carymrobbins
Copy link
Owner

@orome Actually no, I am using it with GHC 8.4.3. See my previous comment here.

@carymrobbins
Copy link
Owner

This seems mostly resolved so long as you're not using GHC 8.2 (which I believe is the only GHC that ghc-mod doesn't support).

@orome
Copy link
Author

orome commented Mar 28, 2019

But ghc-mod can't be built with base>=4.10, right? So I can't use it with a project that uses the latest GHC or LTS.

@carymrobbins
Copy link
Owner

Actually no, I'm currently using LTS 13.x and ghc-mod works. I have some steps outlined here that might help - http://caryrobbins.com/dev/installing-ghc-mod/

Ideally, we should get something like this workflow packaged up to make it easier for folks to install and configure ghc-mod (which is related to #304).

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

No branches or pull requests

3 participants