
There is a safe package on hackage that has variations on head, headMay
which uses maybe, headNote which allows you to put a more descriptive error
should it fail, and headDef which allows you to specify a default, should
it fail.
But the most common way of dealing with it is not to use head except in
extremely simple cases. You can grep some substantial codebases like yesod
and see maybe two or three actual heads in the code. People tend to use
pattern matching on lists or case statements on the list.
On Sun, Mar 31, 2013 at 11:42 AM, Nathan Hüsken
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/beginnershttp://www.haskell.org/mailman/listinfo/beginners