Skip to content

Code action to remove redundant constraints can't deal with type operators properly #1300

Open
@berberman

Description

@berberman

Your environment

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

haskell-language-server version: 0.9.0.0 (GHC: 8.10.3) (PATH: /home/berberman/.cabal/store/ghc-8.10.3/haskell-language-server-0.9.0.0-81f61f357a41d74a3d6d524b9f8f4949ec5bbcb5dd08161f78f8859c0cd951c1/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          Not found
ghc:            8.10.3

Which lsp-client do you use:
vscode

Steps to reproduce

Create a haskell file like this, then try applying code actions to remove redundant constraints:

{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wredundant-constraints #-}

class a ** b

f :: (**) a b => a -> b -> a
f = const

g :: ((**) a b) => a -> b -> a
g = const

h :: ((**) a b, Eq a) => a -> b -> a
h = const

Expected behaviour

It results in:

{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wredundant-constraints #-}

class a ** b

f :: a -> b -> a
f = const

g :: a -> b -> a
g = const

h :: a -> b -> a
h = const

Actual behaviour

  • f's type signature became f :: **) a => a -> b -> a
  • no code action populated for g
  • h's type signature became h :: (**) a b => a -> b -> a

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions