fromJust Nothing problem
Neil Mitchell
ndmitchell at gmail.com
Tue Nov 14 07:00:29 EST 2006
Hi
> My last impression is that instead of using -xc it is better to write
> programs in a debug-friendly style. For example, let g x must
> return (Just _), but the programmer is not 100% sure that g x is free
> of bugs. Then, instead of
> f x = h $ fromJust $ g x
> one needs too write
There are lots of solutions I use, all of which I think are nicer than your one!
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
Neil
More information about the Glasgow-haskell-users
mailing list