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

Henning Thielemann lemming at henning-thielemann.de
Fri Nov 17 07:30:29 EST 2006

On Fri, 17 Nov 2006, Neil Mitchell wrote:

> Hi
> > > How controversial would a proposal to {-# DEPRECATE fromJust #-} be, in
> > > favour of:
> > >
> > >     Just _ = x  -- which will give you the precise line number
> > > It seems to me this is one cause of mysterious newbie errors we
> > > could easily discourage, with little harm.
> > 
> > Btw, I'm not seriously suggesting removing it ;)
> > It could be discouraged ever so slightly in the haddocks though.
> I strongly disagree. If we are removing things that confuse newbies
> why not start with higher rank types, MPTC's and GADT's ;)
> fromJust is simple, useful and clear. What you mean is that
> implementations aren't very good at debugging this. It seems unfair to
> blame partial functions for the lack of a debugger. If a call stack
> was automatically output every time a fromJust failed would this even
> be something people complained about?

It seems to me like the discussion about static typesafety vs. no or weak
typesafety. (Which still exists with respect to several Haskell
libraries.) Of course, all type errors can be catched also by a debugger.  
So was the decision of making Haskell statically type-safe only made in
order to be freed of writing a debugger? Certainly not, because type
checks can catch errors early and precisely, that is, better than any
debugger. That's also true for DEPRECATE fromJust.  Give the user a hint
early, that his decision of using fromJust is shortsighted and is possibly
due to unfortunate program design.

More information about the Haskell-Cafe mailing list