[Haskell-cafe] Debugging partial functions by the rules

Jason Dagit dagit at eecs.oregonstate.edu
Fri Nov 17 21:42:57 EST 2006

This good long thread prompted Don and I to take a look at the darcs
source (this is current darcs-unstable).  You can get the darcs source
darcs get http://abridgegame.org/repos/darcs-unstable

Here are some data points (without interpretation):

In impossible.h we have the definitions:
import Bug ( bug )
#define impossible (bug $ "Impossible case at "++__FILE__++":"++show
(__LINE__ :: Int)++" compiled "++__TIME__++" "++__DATE__)

#define fromJust (\m_fromJust_funny_name -> case m_fromJust_funny_name
of {Nothing -> bug ("fromJust error at "++__FILE__++":"++show
(__LINE__ :: Int)++" compiled "++__TIME__++" "++__DATE__); Just x ->

The second definition gives bug reports like the following:
fromJust error at Push.lhs:136 compiled 11:51:58 Jun 16 2006
Please report this to bugs at darcs.net,
If possible include the output of 'darcs --exact-version'.

To see at a glance the various bug reports about fromJust you can
search the bug database:

I count 7 bugs.

Some other datapoints:
$ grep fromJust *.lhs *.hs | wc -l
$ grep fromMaybe *.lhs *.hs | wc -l
$ grep maybe *.lhs *.hs | wc -l

I would be interested to see the results of static analysis tools
(Catch?) or applying Oleg's strategy.  Any volunteers?


More information about the Haskell-Cafe mailing list