fromJust Nothing problem

Neil Mitchell ndmitchell at
Tue Nov 14 07:00:29 EST 2006


> 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:
- 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: - sometimes works

Use Catch to prove the absence of pattern match errors: - 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!



More information about the Glasgow-haskell-users mailing list