Hi all,
Recently, I participated in a coding competition.
As part of it, I had to write a program wherein I had to make my data-type
an instance of Ord. An error in my implementation of compare resulted in me
losing quite a bit of valuable time.
As I wrote it, I had tested it out on the ghci and it seemed to work fine
but I noticed that there was trouble when the List.sort started giving weird
output. I then noticed that for certain instances (say t1,t2), both compare
t1 t2 AND compare t2 t1 returned LT. Once I spotted it, it was easy enough
to fix but I did lose an hour or so thinking something went wrong before I
fed the list to the sort function.
I was the only haskeller in the competition and I believe am among the first
to finish a correct application (by a large margin, and) and I did manage to
raise a bit of haskell-awareness, but if I had managed to spot the error
earlier, the results would have been dazzling.
Does any one here have any advice on dealing with such maladroitness on the
part of the programmer, especially while creating instances to
type-classes?
Thanks and regards,
Hemanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090529/86d8b508/attachment.html