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

Emmanuel Touzery etouzery at gmail.com
Sun Mar 31 23:03:31 CEST 2013

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:


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


On Sun, Mar 31, 2013 at 5:42 PM, Nathan Hüsken <nathan.huesken at 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 at haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130331/ba17aec4/attachment.htm>

More information about the Beginners mailing list