I'm beginner of haskell.
Now I'm struggling to resolve negative index exception.
But unlike other common language, it seems to me that haskell doesn't show line number where exception occured.
Is it possible to know the line number where exception occured?
These days there are basically two good ways.
Liberally sprinkle HasCallStack
constraints through your code, as in
foo :: HasCallStack => Int -> [a] -> a
foo n xs = xs !! n
Compile with -prof
and pass the -xc
RTS flag, as in
ghc -prof foo.hs && ./foo +RTS -xc
The latter is easier, the former gives you more control over exactly what things are considered "interesting enough" to put in a stack trace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With