fromJust Nothing problem
Serge D. Mechveliani
mechvel at botik.ru
Wed Nov 15 03:09:02 EST 2006
On Tue, Nov 14, 2006 at 05:28:22PM +0000, Simon Peyton-Jones wrote:
> Both of these messages (from Neil and Serge) suggest use debugging ideas.
> Would anyone like to add them to
> http://haskell.org/haskellwiki/Debugging
> [..]
How can I put it there? It needs login.
I do not know, whether my idea worths it, but, for any occasion, here is
its new formulation
-----------------------------------------------------------
Maybe, the simplest way to provide locating in the source code a mismatch
run-time error in the library functions
head, tail, fromJust, and such,
is to avoid these functions and to use explicit matching instead.
For example, for the program g x = h $ fromJust $ f x,
ghc-6.6 often looses the reference to g, f, and h in its run-time error
report -- when f returns Nothing.
But for the program
g x = let Just y = f x in h y,
the ghc run-time report is like this:
Main: M1.hs:9:11-22:
Irrefutable pattern failed for pattern Data.Maybe.Just y
-- it points to the source line!
----------------------------------------------------------------------
-----------------
Serge Mechveliani
mechvel at botik.ru
More information about the Glasgow-haskell-users
mailing list