[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
at:
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 ->
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:
http://bugs.darcs.net/issue?@columns=id%2Cactivity%2Ctitle%2Ccreator%2Cassignedto%2Cstatus&@sort=activity&@group=priority&@search_text=fromJust

I count 7 bugs.

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

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

thanks!
Jason


More information about the Haskell-Cafe mailing list