I asked more or less the same question in august 2012.

as I have gained more experience with Haskell, the problem has become less important and I think it will be the same with you. But there is a better solution than Maybe and others, haskell can give you a stack trace if you compile with profiling enabled:

http://marc.info/?t=135220245600002&r=1&w=4

I now make sure to compile all my libraries with profiling enabled, just in case I may need it...

emmanuel


On Sun, Mar 31, 2013 at 5:42 PM, Nathan Hüsken <nathan.huesken@posteo.de> wrote:
Hey,

I have written a program which, when executed produces:

  Main: Prelude.head: empty list

Now, I can go through my program and replace all "head" with

  (\a -> trace ("<line-nr>: length=" ++ (show (length a))) a)

Actually, I already did that, and by this I found the error.
But I wonder if there would have been an easier way?
Has anyone any debug advice how I could find out which call to "head" causes this without so much typing work?

Thanks!
Nathan

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners