GHCi and line numbers (with ghc-7.4.1)

Christopher Done chrisdone at
Thu Mar 22 12:36:12 CET 2012

On 22 March 2012 12:13, Simon Marlow <marlowsd at> wrote:
> On 20/03/2012 20:12, Simon Hengel wrote:
>> They are now incremented with each evaluated expression.

Why *are* they incremented with each evaluation? Surely the only use
for line numbers would be in multi-line statements:

> :{
Prelude| do x <- [1..10]
Prelude|    return y
Prelude| :}

<interactive>:6:11: Not in scope: `y'

Would it not make more sense to have

<interactive>:2:11: Not in scope: `y'

as it would do if compiling the file in a source file? From the older
GHCs, this always gives 1, indicating that multi-line statements are
somehow parsed and collapsed before being compiled, or maybe the line
number was just hard coded to 1.

FWIW, in my Emacs mode (making good progress on adding to
haskell-mode) I use the column number in the REPL to highlight on the
line where the problem is (e.g. here, for GHC 7.* with
proper multi-line support I will automatically wrap any multi-line
expressions entered in the REPL in :{ and :}, it would be cool for
line numbers in errors to be useful for that. (Arguably we should be
using the GHC API and Scion or something like it, but these change
quite often and are hard to support whereas interfacing with GHCi is
quite stable across around seven releases and "just works".)

More information about the Glasgow-haskell-users mailing list