[Haskell-cafe] Haskell stacktrace

Paul Johnson paul at cogito.org.uk
Wed Sep 10 14:59:47 EDT 2008

Pieter Laeremans wrote:
> Hello,
> I've written a cgi script in haskell, it crashes sometimes  with the 
> error message Prelude . tail  : empty list
Yup, been there, done that.

First, look for all the uses of "tail" in your program and think hard 
about all of them.  Wrap them in "assert" or "trace" functions to see if 
there are any clues to be had.

Then take a look at the GHC debugger documentation.  Debuggers for lazy 
languages (or indeed any language with closures) is difficult because 
execution order isn't related to where the faulty data came from.  So if 
I say somewhere

   x = tail ys

and then later on

   print x

the "print" will trigger the error, but the faulty data "ys" may no 
longer be in scope, so you can't see it.

More information about the Haskell-Cafe mailing list