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

GADT syntax converter throws out all datatype comments #3516

Closed
uhbif19 opened this issue Mar 10, 2023 · 6 comments
Closed

GADT syntax converter throws out all datatype comments #3516

uhbif19 opened this issue Mar 10, 2023 · 6 comments
Labels
component: hls-gadt-plugin Issues related to the hls-gadt-plugin, such as converting a datatype to GADT syntax type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@uhbif19
Copy link
Collaborator

uhbif19 commented Mar 10, 2023

Your environment

haskell-language-server version: 1.8.0.0 (GHC: 8.10.7)

VS Code

Steps to reproduce

Run rewrite to GADT action on:

data AuctionTerms = AuctionTerms
  { -- | What is being sold at the auction?
    auctionLot :: !AssetClass
  }

Expected behaviour

Got:

data AuctionTerms where
  AuctionTerms :: {
     -- | What is being sold at the auction?
     auctionLot :: !AssetClass
  } -> AuctionTerms

Actual behaviour

Got:

data AuctionTerms where
  AuctionTerms :: {auctionLot :: !AssetClass} -> AuctionTerms
@uhbif19 uhbif19 added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Mar 10, 2023
@fendor fendor added component: hls-gadt-plugin Issues related to the hls-gadt-plugin, such as converting a datatype to GADT syntax and removed status: needs triage labels Mar 10, 2023
@July541
Copy link
Collaborator

July541 commented Apr 16, 2023

It's a known limitation because dealing with comment much harder for me.

Any improvements are welcomed!

@July541 July541 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2023
@uhbif19
Copy link
Collaborator Author

uhbif19 commented Apr 16, 2023

@July541 Could you point to any relevant parts of code or issues? Like are there any parts of HLS which do handle comments?

@July541
Copy link
Collaborator

July541 commented Apr 16, 2023

Sure. @uhbif19

#2899 (comment) and #2899 (comment) and #2899 (comment) are some discussion described the pain while dealing with comment.

For code details, https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs#L88 used to convert data declarations to GADT syntax, all comments are dropped here.

While stepping in these codes, you may find the differences between different versions of ghc-exactprint, and another problem is how to identify the comments, comments can be attached to several elements.

Like are there any parts of HLS which do handle comments?

  • ghcide has a simple handwritten parser to parse comments for top level definition, this is not what we want.
  • hls-tactics-plugin has some module to work with ghc-exactprint, not sure if there is something about comments, but it doesn't work with ghc9.2+.
  • hls-haddock-comment-plugin attach comments to function, but it is used to add comments instead of reading comments.

@uhbif19
Copy link
Collaborator Author

uhbif19 commented Apr 16, 2023

Thanks for references!

I also have comment duplicating bug with "Add import" refactoring, so that is probably related to ghcides "simple handwritten parser" too.

@July541
Copy link
Collaborator

July541 commented Apr 17, 2023

I also have comment duplicating bug with "Add import" refactoring

Do we have a related issue?

@uhbif19
Copy link
Collaborator Author

uhbif19 commented Apr 17, 2023

@July541 I could not find anything matching it. I can create new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-gadt-plugin Issues related to the hls-gadt-plugin, such as converting a datatype to GADT syntax type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants