[Haskell-cafe] Type System vs Test Driven Development

Serge Le Huitouze serge.lehuitouze at gmail.com
Wed Jan 12 13:45:22 CET 2011

Henning Thielemann <lemming at henning-thielemann.de> wrote:
>> A code doing addition and substraction of some sort.
>> A property such as "X = (X add Y) sub Y" is easily falsifiable when
>> the number of bits of your integer is too small for your numbers.
> Since fix-width words represent modulo-arithmetic, your law would even hold
> in case of overflows.

True in this very example, but it's overly simplistic and I chose it
just for the
sake of illustration.
A property such as "X = (X mul Y) div Y", with Y != 0 (of course ;-),
Y prime wrt
2^nbBits (nbBits being the size of your integers), and the intermediate product
exceeding 2^nbBits would fail miserably...


More information about the Haskell-Cafe mailing list