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

Lambda case quick action format instance heads #1674

Closed
eviefp opened this issue Apr 6, 2021 · 3 comments
Closed

Lambda case quick action format instance heads #1674

eviefp opened this issue Apr 6, 2021 · 3 comments
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@eviefp
Copy link

eviefp commented Apr 6, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.0.0.0 (GHC: 8.10.2) (PATH: /nix/store/b3jr5z4hzv4vsysi0g7r1dx2a9ndi1ja-haskell-language-server-1.0.0.0/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1.1
ghc:		8.10.2

Which OS do you use: NixOS

Which lsp-client do you use: emacs

Steps to reproduce

When filling in a typed hole in a class method with a lambda case split, the whole instance head/decl gets reformatted. This project has stylish-haskell setup and does not touch instances.

Expected behaviour

Use the code formatter or not touch the instance head.

E.g., for this code:

instance
  ( Cast (GBoolExp b a) (GBoolExp b' a')
  , Cast a a'
  ) => Cast (GBoolExp b a) (GBoolExp b' a') where
    cast = _

When doing "lambda case split" on the _, I get this:

instance (Cast (GBoolExp b a) (GBoolExp b' a'), Cast a a') =>
         Cast (GBoolExp b a) (GBoolExp b' a') where
  cast
    = \case
        (BoolAnd l_gb'a') -> _
        (BoolOr l_gb'a') -> _
        (BoolNot gb'a') -> _
        (BoolExists gb'a') -> _
        (BoolFld a') -> _

What I would expect is this:

instance
  ( Cast (GBoolExp b a) (GBoolExp b' a')
  , Cast a a'
  ) => Cast (GBoolExp b a) (GBoolExp b' a') where
  cast
    = \case
        (BoolAnd l_gb'a') -> _
        (BoolOr l_gb'a') -> _
        (BoolNot gb'a') -> _
        (BoolExists gb'a') -> _
        (BoolFld a') -> _
@googleson78
Copy link
Contributor

googleson78 commented Apr 6, 2021

This is also an issue when introducing a lambda or a lambda case split in functions with top level pattern matching. If I introduce a lambda in the second case of such a function, hls will also reformat my first case

@Ailrun Ailrun added component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Apr 6, 2021
@isovector
Copy link
Collaborator

I am 95% sure this is fixed in HEAD (via #1543). Mind compiling from source?

@jneira jneira added status: fixed in master status: needs info Not actionable, because there's missing information labels Apr 6, 2021
@jneira
Copy link
Member

jneira commented Apr 16, 2021

The fix should be included in the hls-1.1.0 release, @Vladciobanu @googleson78 feel free to reopen if it does not fix the issue for you

@jneira jneira closed this as completed Apr 16, 2021
@jneira jneira removed the status: needs info Not actionable, because there's missing information label Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wingman 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

5 participants