[Haskell-cafe] Debugging methods for haskell

Marc Weber marco-oweber at gmx.de
Wed Jul 15 19:34:22 EDT 2009

Of course !! is only one cause for this kind of errror. Another is
ghci> head []
*** Exception: Prelude.head: empty list

Unfortunately this kind of bug is very hard to debug due to the lazy
nature of haskell. You don't have a stack trace as in Java, PHP, ..

data D = D String

a,b :: [String]
a = head []
b = head []

main = do
  let first = a
      second = b

  print first -- both will cause the same error but a different head caused the exception
  print second

One solution is using interlude from hackage. I'm not sure wether it
supports !!

Also try this haskell-cafe search (you may have to up to page 20 or so)

This reveals this thread for example:

I recall there was another method. Yeah, I even found it (using ghci and set -fbreak-on-exception)

Marc Weber

More information about the Haskell-Cafe mailing list