Or define your own ghead and gtail:

ghead msg [] = error "ghead " ++ msg ++ "[]"
ghead _ (x:xs)  = x


gtail msg [] = error "gtail" ++ msg ++ "[]"
gtail msg (x:xs) = xs

and you can call them with a name of a function to give you an idea where
the error is occurring:

myHead = ghead "myHead" []

Chris.


On Tue, 9 Sep 2008, Ketil Malde wrote:

> "Justin Bailey" <[EMAIL PROTECTED]> writes:
>
> > are using tail (or could be calling something that uses tail) and use
> > the "trace" function to output logging info.
>
> Another cheap trick is to use CPP with something like:
>
> #define head (\xs -> case xs of { (x:_) -> x ; _ -> error("head failed at 
> line"++__FILE__++show __LINE__)})
>
> -k
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to