[Haskell-cafe] Using quickcheck to check for errors

Kim-Ee Yeoh ky3 at atamo.com
Sat Jun 7 19:40:50 UTC 2014

On Sun, Jun 8, 2014 at 1:56 AM, Rafael Almeida <almeidaraf at gmail.com> wrote:

> Let's say we want to quickcheck the function !!. Passing a negative index
> to it is an error. However, how can you make a check that it indeed errors
> in such situation?

The problem is that (!!) is a partial function, like head. How would you
check that head [] is an error?

What you could do is quickcheck a safe version of (!!) -- see Safe.atMay --
that returns a Maybefied type.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140608/7fe8e03a/attachment.html>

More information about the Haskell-Cafe mailing list