[Haskell-beginners] finding the cause of an error (here head: empty list)

Nathan Hüsken nathan.huesken at posteo.de
Sun Mar 31 17:42:16 CEST 2013


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?


More information about the Beginners mailing list