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

Inline function with guard only pick first guard case #4374

Open
guibou opened this issue Aug 3, 2024 · 7 comments
Open

Inline function with guard only pick first guard case #4374

guibou opened this issue Aug 3, 2024 · 7 comments
Labels
component: hls-refactor-plugin Issues related to the hls-refactor-plugin component: hls-retrie-plugin status: blocked Not actionable, because blocked by upstream/GHC etc. type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@guibou
Copy link
Collaborator

guibou commented Aug 3, 2024

Your environment

Which OS do you use? Linux
Which version of GHC do you use and how did you install it?

Tested with ghc 9.6.5 and 9.8.2 installed with nix.

How is your project built (alternative: link to the project)?

Single file

Which LSP client (editor/plugin) do you use?

neovim + neovim-lsp

Which version of HLS do you use and how did you install it?

2.9.0.0 installed from nixpkgs.

Have you configured HLS in any way (especially: a hie.yaml file)?

No hie file, single file support

Steps to reproduce

The following file:

foo x y
  | x == 0 = y
  | otherwise = x + y

bar = foo 1 2

The code action on the foo call, called inline foo

Expected behaviour

foo (in bar)should be replaced by equivalent piece of code, so I assume something like:

bar = if 1 == 0 then 2 else 1 + 2

(or something equivalent).

Actual behaviour

Looks like only the first case of foo implementation is taken into account, and hence, I get:

bar = 2

See for yourself:

hls_inline_bug.mp4

Debug information

@guibou guibou added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Aug 3, 2024
@fendor
Copy link
Collaborator

fendor commented Aug 5, 2024

Hi, thanks for the bug report! Iirc, this feature is implemented by retrie. Is this reproducible with retrie as well, or only in HLS?

@soulomoon
Copy link
Collaborator

soulomoon commented Aug 5, 2024

I manually test it in retrie, It is retrie's problem.

@fendor fendor added the status: blocked Not actionable, because blocked by upstream/GHC etc. label Aug 5, 2024
@soulomoon
Copy link
Collaborator

soulomoon commented Aug 5, 2024

Issue created in retire facebookincubator/retrie#71

@guibou
Copy link
Collaborator Author

guibou commented Aug 13, 2024

Thank you for the test with retrie

@michaelpj
Copy link
Collaborator

Given that retrie is apparently not being actively maintained, perhaps we should deprecate the retrie plugin?

@guibou
Copy link
Collaborator Author

guibou commented Sep 5, 2024

@michaelpj

Given that retrie is apparently not being actively maintained, perhaps we should deprecate the retrie plugin?

Yes, for sure. However, the fold / unfold (e.g. replace symbol by implementation) is part of our refactoring logic (we export "deprecated" pattern synonyms and "smart constructor" and ask our (internal) users to just unfold at call site using the code action.

This thing is a terrific quality of life tool. Do you think a subset of retrie can be imported into HLS in order to keep at least the "replace by implementation" code action?

edit I really have the feeling that I'm programming with "The Rocq Prover" in my haskell editor and that's something which makes me like my job ;)

@michaelpj
Copy link
Collaborator

I mean, we don't need to take it out urgently, perhaps retrie will continue to work for a while. But in the long run either someone needs to keep it going or write a replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-refactor-plugin Issues related to the hls-refactor-plugin component: hls-retrie-plugin status: blocked Not actionable, because blocked by upstream/GHC etc. 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

4 participants