haskell / haskell/haskell-language-server

Compliled-in fourmolu 1.4.0.0 in HLS 2.4.0.0 formats differently than standalone compiled fourmolu 1.4.0.0

Open
#3,882 7 comments 1 reaction 0 assignees View on GitHub
component: formatters status: blocked type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
4d 3h
Merged PRs (30d)
12

Description

### Your environment

Which OS do you use?

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

9.6.3 from nix
How is your project built (alternative: link to the project)?
cabal

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

VSCode + Haskell extension
Which version of HLS do you use and how did you install it?

2.4.0.0 from nix
Have you configured HLS in any way (especially: a `hie.yaml` file)?
No

### Steps to reproduce

Create code that has an infix operator leading on a line, e.g.:

```
module Main where

import qualified Data.Map.Strict as M

main :: IO ()
main = do
let foo =
M.fromList
$ zipWith
(+)
[0 .. 9]
[10, 20 .. 30]
pure ()
```

Format it via VSCode (Shift+Alt+F): It remains the same.

Format it on the command line using `fourmolu path/to/Main.hs`. It comes out with the `$` on the end of the previous line:

```
main :: IO ()
main = do
let foo =
M.fromList $
zipWith
(+)
[0 .. 9]
[10, 20 .. 30]
pure ()
```

### Expected behaviour

HLS in VSCode should format it with the `$` trailing after `M.fromList`.

### Actual behaviour

HLS in VSCode formats it with the `$` leading before `zipWith`.

### Debug information

On the command line:

```
$ fourmolu --version
fourmolu 0.14.0.0
using ghc-lib-parser 9.6.3.20231014
```

In the HLS log within VSCode:

```
2023-11-27T17:37:51.110548Z | Debug | fourmolu: Using compiled in fourmolu-0.14.0.0
```

Note that it doesn't say what version of `ghc-lib-parser` it's using. Maybe that makes the difference? Was it compiled with `ghc-lib-parser 9.6.2`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.