stylish-haskell
stylish-haskell copied to clipboard
Imports that are not on top of file are not parsed properly.
Hello! There is parse error while parsing some files with imports inside of file (this is possible when using CPP extension). Example file, which is not parsed correctly can be found in Cabal install: https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/Win32SelfUpgrade.hs
(there are imports on lines 209 and 210)
Thanks for reporting, we appreciate it! I'm keeping this issue open as a reminder for myself, but please report parsing issues directly to haskell-src-exts, the library we use for parsing Haskell.
Thank you for the information. I've reported bug to haskell-src-exts: https://github.com/haskell-suite/haskell-src-exts/issues/68
haskell-src-exts cannot parse CPP. Instead, it expects to see preprocessed Haskell source. There's the hse-cpp package which does that.
However, that wouldn't help stylish-haskell because it wants to pretty-print the code back, and that'd strip all the CPP stuff and code that wasn't included by conditional compilation.
I don't think there's much you can do about it. Consider it a limitation of haskell-src-exts & stylish-haskell, and/or the price to pay for CPP.
Right, thanks for the input @feuerbach!