Closed Alecton4 closed 8 months ago
Can reproduce with ormolu only:
Looks like ormolu tries to parse the literate haskell file as a haskell file. Maybe ormolu cannot parse .lhs
files?
Would you mind reporting this issue upstream?
@fendor Thanks! I will report this upstream. BTW, do you suggest any other formatter that deals with literal Haskell and could be integrated with the VSCode extension?
HLS comes with a number of formatters such as stylish-haskell
, fourmolu
, ormolu
and floskell
. You switch them with Settings > Extensions > Haskell: Formatting Provider
.
fourmolu
is based off ormolu
, thus has the same issue. stylish-haskell
barely formats, mainly unifies the imports and I haven't used floskell before, I think. (Brittany is also in the list, but has been removed in recent HLS releases).
So, give floskell
a try, maybe you are lucky :)
Update: Tried floskell
and it failed with the following message:
2023-12-18T10:11:20.558419Z | Error | floskell: Internal Error: floskellCmd: /home/az/workspace/playground-Haskell/playground/Stdm.lhs:6:1: TemplateHaskell language extension is not enabled. Please add {-# LANGUAGE TemplateHaskell #-} pragma at the top of your module.
[Error - 6:11:20 PM] Request textDocument/formatting failed.
Message: floskell: Internal Error: floskellCmd: /home/az/workspace/playground-Haskell/playground/Stdm.lhs:6:1: TemplateHaskell language extension is not enabled. Please add {-# LANGUAGE TemplateHaskell #-} pragma at the top of your module.
Code: -32603
After adding {-# LANGUAGE TemplateHaskell #-}
to the top of the .lhs
file, it failed with the following message:
2023-12-18T10:15:29.624716Z | Error | floskell: Internal Error: floskellCmd: /home/az/workspace/playground-Haskell/playground/Stdm.lhs:7:1: Parse error: Last
[Error - 6:15:29 PM] Request textDocument/formatting failed.
Message: floskell: Internal Error: floskellCmd: /home/az/workspace/playground-Haskell/playground/Stdm.lhs:7:1: Parse error: Last
Code: -32603
Yeah, that looks like it does not understand literate haskell files, I am sorry, it seems you are out of luck :(
Your environment
Steps to reproduce
Expected behaviour
The file should be formatted, I guess.
Actual behaviour
An error occur:
Debug information
The log in the output panel: