[Haskell-cafe] Re: Debugging partial functions by the rules

Donald Bruce Stewart dons at cse.unsw.edu.au
Fri Nov 17 01:59:52 EST 2006


dmhouse:
> On 16/11/06, oleg at pobox.com <oleg at pobox.com> wrote:
> >And if we are absolutely positive that the value is (Just x),
> >we can always write
> >        maybe (assert False undefined) id v
> 
> It should be pointed out that Data.Maybe does export a less well-known
> function, fromMaybe:
> 
> fromMaybe z = maybe z id
> 
> This can be used to make the 'maybe X id' case a bit tidier (although
> technically it's not a save on characters).

How controversial would a proposal to {-# DEPRECATE fromJust #-} be, in
favour of:

    Just _ = x  -- which will give you the precise line number

    maybe (assert False)

    maybe id

    fromMaybe

It seems to me this is one cause of mysterious newbie errors we 
could easily discourage, with little harm.

-- Don


More information about the Haskell-Cafe mailing list