Skip to content

Brittany is not initialised with stack default extensions #665

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

Closed
santiweight opened this issue Dec 12, 2020 · 7 comments
Closed

Brittany is not initialised with stack default extensions #665

santiweight opened this issue Dec 12, 2020 · 7 comments
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: enhancement New feature or request

Comments

@santiweight
Copy link
Collaborator

santiweight commented Dec 12, 2020

I am unsure whether this is a feature request or a bug...

VS Code - haskell extension

Bug repro

https://github.com/santiweight/hls-bug-brittany

See the diff for the most recent commit

Contents of hie.yaml:

cradle:
  stack:
    component: "hls-bug-brittany:lib"

Steps to reproduce

Have a syntactic extension (e.g. PatternSynonyms) in package.yaml's default extensions and then pretty print using Brittany.

Expected behaviour

Pretty printing should occur

Actual behaviour

Error prints:

santiweight/hls-bug-brittany/src/Lib.hs
2020-12-11 18:27:42.718845 [ThreadId 5982] - Plugin ModuleName  prefix Just "/Users/santiweight/hls-bug-brittany/src"
2020-12-11 18:27:42.718885 [ThreadId 5982] - Plugin ModuleName  mdlName Just "Lib"
2020-12-11 18:27:42.718989 [ThreadId 5991] - finish: ModuleName.GetParsedModule (took 0.00s)
2020-12-11 18:27:42.719014 [ThreadId 5982] - Plugin ModuleName  correct Just "Lib" stated Just (Range {_start = Position {_line = 0, _character = 7}, _end = Position {_line = 0, _character = 10}},"Lib")
2020-12-11 18:27:42.71907 [ThreadId 5982] - Plugin ModuleName  actions []
2020-12-11 18:27:42.719291 [ThreadId 7] - <--2--{"result":[],"jsonrpc":"2.0","id":127}
2020-12-11 18:27:43.886555 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":128,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///Users/santiweight/hls-bug-brittany/src/Lib.hs"},"options":{"tabSize":4,"insertSpaces":true}}}
2020-12-11 18:27:43.886895 [ThreadId 5997] - finish: Formatter (took 0.00s)
2020-12-11 18:27:43.886922 [ThreadId 5996] - Formatter.doFormatting: contents="module Lib\n    ( someFunc\n    ) where\n\nsomeFunc :: IO ()\nsomeFunc = putStrLn \"someFunc\"\n\nnewtype Bar a = Bar a\n\npattern Foo :: Int -> Bar Int\npattern Foo a = Bar a\n\n"
[Error - 6:27:43 PM] Request textDocument/formatting failed.
  Message: brittanyCmd: stdin:10:1-11: Invalid type signature: pattern Foo :: ...
Perhaps you meant to use PatternSynonyms?

  Code: -32602
2020-12-11 18:27:43.89336 [ThreadId 7] - <--2--{"error":{"code":-32602,"message":"brittanyCmd: stdin:10:1-11: Invalid type signature: pattern Foo :: ...\nPerhaps you meant to use PatternSynonyms?\n"},"jsonrpc":"2.0","id":128}
@Ailrun
Copy link
Member

Ailrun commented Dec 12, 2020

Is {- # LANGUAGE PatternSynonyms #-} correct pragma?
I think that's invalid...

@santiweight
Copy link
Collaborator Author

This was simply so you can enable/disable easily - it's a comment until you remove the whitespace

@santiweight
Copy link
Collaborator Author

The point being that since the extension was inactive (the pragma was commented out), the bug arose

@Ailrun

This comment has been minimized.

@Ailrun
Copy link
Member

Ailrun commented Dec 12, 2020

Sorry, I have misread the issue. So the problem is that Brittany does not recognize the extension in package.yaml, right?
Then I would say this one is more like an enhancement than a bug, as the original Brittany command also requires an extra config file with an extension list to apply them by default.

@Ailrun Ailrun added the type: enhancement New feature or request label Dec 12, 2020
@santiweight
Copy link
Collaborator Author

@Ailrun I believe this to be the case. I'm not aware whether hls picks up the config in package.yaml. If so, this might not be such a hard enhancement. I can always take a look if someone is willing to point me somewhere in the code :)

@jneira
Copy link
Member

jneira commented Feb 24, 2021

Afaik this should be closed by #1362, @santiweight could you confirm brittany honours stack default extensions?

@jneira jneira closed this as completed Feb 24, 2021
@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. and removed status: needs attention labels Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants