[Haskell-cafe] Re: Haskell stacktrace
C.M.Brown
cmb21 at kent.ac.uk
Tue Sep 9 17:21:24 EDT 2008
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" <jgbailey at gmail.com> 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
>
More information about the Haskell-Cafe
mailing list