haskell / haskell/haskell-language-server
"Remove all redundant imports" sometimes breaks code
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 12
Description
### Your environment
Which OS do you use?
ArchLinux
Which version of GHC do you use and how did you install it?
9.14.1 from ghcup
How is your project built (alternative: link to the project)? see below
Which LSP client (editor/plugin) do you use?
Terminal Vim + YCM
Which version of HLS do you use and how did you install it?
2.14.0.0 from ghcup
Have you configured HLS in any way (especially: a `hie.yaml` file)? no
### Steps to reproduce
- `Main.hs`
```haskell
module Foo where
import Control.Monad.Trans.Maybe (MaybeT (MaybeT), hoistMaybe)
go :: MaybeT IO a
go = _
```
- `cabal.project`
```cabal
packages: .
package *
ghc-options: -Wunused-imports
with-compiler: ghc-9.14.1
```
- `app.cabal`
```cabal
cabal-version: 3.4
name: app
version: 0.1.0.0
executable app
main-is: Main.hs
build-depends: base, transformers
hs-source-dirs: .
default-language: GHC2024
```
### Expected behaviour
"Remove all redundant imports" should turn this
```haskell
import Control.Monad.Trans.Maybe (MaybeT (MaybeT), hoistMaybe)
```
into either of these
```haskell
import Control.Monad.Trans.Maybe (MaybeT ())
import Control.Monad.Trans.Maybe (MaybeT)
```
### Actual behaviour
The result is instead this
```haskell
import Control.Monad.Trans.Maybe (hoistMaybe)
```
### Debug information
Not sure.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue using Main.hs, cabal.project, and app.cabal with GHC 9.14.1 and HLS 2.14.0.0, then trace the “Remove all redundant imports” action and its existing tests; done means the import is reduced to one of the expected valid forms without removing the MaybeT constructor needed by go.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100