implicit-hie
implicit-hie copied to clipboard
Confusing parsing behaviour when a list is the last thing in the .cabal file
trafficstars
I ran into some rather confusing behaviour when I used gen-hie with a cabal file that ended with an other-modules list. I loaded Hie.Cabal.Parser into GHCi to confirm this.
Test cabal file (to be parsed with/without a final newline):
name: foo
executable bar
main-is: Main.hs
other-modules: Hello
, World
This file seems to miss World both with/without the final newline.
λ> parsePackage' "name: foo\nexecutable bar\n main-is: Main.hs\n other-modules: Hello\n , World"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs"])
λ> parsePackage' "name: foo\nexecutable bar\n main-is: Main.hs\n other-modules: Hello\n , World\n"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs"])
Test cabal file (to be parsed with/without a final newline):
name: foo
executable bar
main-is: Main.hs
other-modules: Hello,
World
This file is parsed different with/without a final newline:
λ> parsePackage' "name: foo\nexecutable bar\n main-is: Main.hs\n other-modules: Hello,\n World"
Right (Package "foo" [Comp Exe "bar" "./Main.hs"])
λ> parsePackage' "name: foo\nexecutable bar\n main-is: Main.hs\n other-modules: Hello,\n World\n"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs",Comp Exe "bar" "./World.hs"])