fromJust Nothing problem

Simon Peyton-Jones simonpj at microsoft.com
Tue Nov 14 12:28:22 EST 2006


Both of these messages (from Neil and Serge) suggest use debugging ideas.  Would anyone like to add them to
        http://haskell.org/haskellwiki/Debugging

Simon

| Use a safe module:
| http://neilmitchell.blogspot.com/2006/11/library-idea-safe-library.html
| - always works, a little bit of effort (I have such a module in my
| code). You then get:
|
| f x = h $ fromJustNote "Foo.f" $ g x
|
| Use Hat: http://haskell.org/hat - sometimes works
|
| Use Catch to prove the absence of pattern match errors:
| http://www-users.cs.york.ac.uk/~ndm/projects/catch.php - I'd say this
| is still too immature for anyone but me to use, but it can be useful.
|
| Use Yhi-stack - still unreleased, but gives out a stack trace on
| crashing. I am trying to push for this to be released soon!
|
| Thanks
|


| More about finding the source of  fromJust Nothing.
|
| For                  g n = fromJust $ f n,
|
| ghc-6.6  often looses the reference to  f  in its run-time error
| report -- when  f  returns  Nothing.
| And this is difficult to locate the source.
| But one could write
|                      g n = let  Just m = f n  in  m,
|
| for which GHC reports
|               Main: M1.hs:9:11-22:
|               Irrefutable pattern failed for pattern Data.Maybe.Just m
|
| -- it points to the source line!


More information about the Glasgow-haskell-users mailing list