-
Notifications
You must be signed in to change notification settings - Fork 14
Description
The Haskell pretty printer should generate {-# LINE ... #-} pragmas so that GHC error messages can point to locations in the source files (instead of locations in the generated files).
Example:
I have a file src/Foo/Bar/Test.shs:
module Foo.Bar.Test where
// main :: IO ()
main = "foo" + 13SugarJ generates the following in bin/Foo/Bar/Test.hs:
module Foo.Bar.Test where
main = ( "foo" + 13 ) where { }This program does not typecheck, because the use of + in line 3 of Test.shs is not correct. GHC reports the problem, but points to line 2 of Test.hs:
C:\eclipse\sugarj\workspace\test-project\bin\Foo\Bar\Test.hs:2:16:
No instance for (Num [Char])
arising from a use of `+'
Possible fix: add an instance declaration for (Num [Char])
In the expression: ("foo" + 13)
In an equation for `main': main = ("foo" + 13)
It would be better if SugarJ could generate the following bin/Foo/Bar/Test.hs instead:
{-# LINE 1 "C:/eclipse/sugarj/workspace/test-project/src/Foo/Bar/Test.shs" #-}
module Foo.Bar.Test where
{-# LINE 3 "C:/eclipse/sugarj/workspace/test-project/src/Foo/Bar/Test.shs" #-}
main = ( "foo" + 13 ) where { }GHC would use the information in the LINE-pragmas to generate the following error message, which points to the correct line in the correct file:
C:\eclipse\sugarj\workspace\test-project\src\Foo\Bar\Test.shs:3:16:
No instance for (Num [Char])
arising from a use of `+'
Possible fix: add an instance declaration for (Num [Char])
In the expression: ("foo" + 13)
In an equation for `main': main = ("foo" + 13)
Even better would be if SugarJ would parse this error messages and display it as an error marker on the line.