[Haskell-cafe] Testing for valid data

Ketil Malde ketil at malde.org
Sat Mar 27 17:20:15 EDT 2010


michael rice <nowgate at yahoo.com> writes:

> When I'm learning a new language I like to translate old programs into
> the new language as a test of my understanding. However, many of the
> old programs are from old programming texts, many written in the time
> of punch-cards for batch processing, and many containing significant
> amounts of code that only tests for valid data. Should we still be
> writing programs in this fashion, or acknowledge the fact that better
> tools for pre-screening data are now available and code only for the
> problem at hand? 

Hm - I remember test suites in a dynamically typed program with test
case upon test case checking that functions expecting integers would
throw an exception when given a string, and so on. Doesn't seem that
long ago either..

I think the whole -- well, no, but half, maybe -- point of Haskell is
that the static type system proves data validity throughout the
program.  And half the trick of writing correct programs is to design
your data types to constrain the possible values to valid ones.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list