O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Brief Introduction to QuickCheck

QuickCheck was originally written in 2000 by Koen Claessen and John Hughes. Their paper on the subject[28] is a detailed introduction. We won’t go into a lot of detail in this chapter, but reading this paper is highly encouraged. To get better acquainted, let’s write a simple property. We’ll use an example directly from the Haskell wiki.[29]

 quickCheck ((\s -> s == s) :: [Char] -> Bool)

We can try it by firing up GHCi.

 $ stack exec ghci
 GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
 Prelude> import Test.QuickCheck
 Prelude Test.QuickCheck> quickCheck ((\s -> s == s) :: [Char] -> Bool)
 +++ OK, passed 100 tests.

First, we import the QuickCheck module. You may have noticed that we did that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required