stylish-haskell icon indicating copy to clipboard operation
stylish-haskell copied to clipboard

ParseFailed on {-# LANGUAGE

Open Cynede opened this issue 12 years ago • 5 comments

Language.Haskell.Stylish.Parse.parseModule: could not parse Google.hs: ParseFailed (SrcLoc {srcFilen ame = ".hs", srcLine = 1, srcColumn = 4}) "Parse error: {-# LANGUAGE"

source:

{-# LANGUAGE UnicodeSyntax #-}
module Google
  ( getLastVersionForPlatform
  , getChromium
  ) where

output

D:\Heather\Contrib\haskell\Cr\src>stylish-haskell.exe -vi Google.hs
D:\Heather\Contrib\haskell\Cr\src\.stylish-haskell.yaml exists
Loading configuration at D:\Heather\Contrib\haskell\Cr\src\.stylish-haskell.yaml
Enabled Imports step
Enabled LanguagePragmas step
Enabled Records step
Enabled TrailingWhitespace step
Extra language extensions: []
Language.Haskell.Stylish.Parse.parseModule: could not parse Google.hs: ParseFailed (SrcLoc {srcFilen
ame = "<unknown>.hs", srcLine = 1, srcColumn = 4}) "Parse error: {-# LANGUAGE"

file was UTF-8

Converted to UTF-8 without BOM, now works...

I'm not sure if that should already works on UTF8 with bom according this commit https://github.com/jaspervdj/stylish-haskell/commit/3598ec21fbd215350940ae064c38f0c756cef916

Also maybe this issue should be merged with https://github.com/jaspervdj/stylish-haskell/issues/3

Cynede avatar Jul 26 '13 12:07 Cynede

Would it be possible to send me the exact file which fails?

jaspervdj avatar Aug 02 '13 18:08 jaspervdj

Sure https://github.com/Heather/Cr/blob/master/src/Google.hs

Cynede avatar Aug 03 '13 05:08 Cynede

Was able to reproduce the error and I think I fixed it. Would you be willing to try out stylish-haskell-0.5.7.0, which I just uploaded to Hackage?

jaspervdj avatar Aug 03 '13 08:08 jaspervdj

Okay, thank you, some later.

Cynede avatar Aug 03 '13 16:08 Cynede

The reason this could happen was not correct BOM skipping when reading file in ASCII mode on Windows. Though, reading in UTF must solve that

dropBom ('\xfeff' : str) = str
dropBom str              = str

danbst avatar May 01 '14 06:05 danbst