[Haskell-beginners] Using QuickCheck to verify that an expression can always be evaluated

Amy de Buitléir amy at nualeargais.ie
Fri Apr 15 15:36:33 CEST 2011

Occasionally I write a QuickCheck test where I want to evaluate
something just to make sure it doesn't crash, but I don't care about
the actual value. For example, in the test below, I just want to make
sure that the expression "foldl' apply newWorkbench gs" doesn't crash.
I don't really care whether or not "devotion w /= -1", that's just an
expression (which is always true) that I wrote to force evaluation of
w. But I assume there's a better way to do this?

prop_all_gene_sequences_are_legal :: [Gene] -> Property
prop_all_gene_sequences_are_legal gs =
  property $ devotion w /= -1
    where w = foldl' apply newWorkbench gs

Thank you in advance for any suggestions.

More information about the Beginners mailing list