<div dir="ltr">Thanks for this respons, Rubén. I might not have explained what I am looking for very well. <div>I already have </div><div>instance Arbitrary Foo </div><div>That is not the problem. The problem is, that when a counterexample is found, it is dumped to the output with the `show` function. I would like to be able to use another function for that, say show'. In order to do so, I need to obtain the counterexample itself in some way, so I can use it to generate a useful message after the tests are done. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Op vr 11 jun. 2021 om 23:31 schreef Ruben Astudillo <<a href="mailto:ruben.astud@gmail.com">ruben.astud@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Han<br>
<br>
On 11-06-21 17:16, Han Joosten wrote:<br>
> [..]<br>
> *parseFoo :: Text -> Guarded Foo*<br>
> *prettyFoo :: Foo -> Text*<br>
> <br>
> The idea is that for all foo :: Foo, the following holds:<br>
>     *parseFoo . prettyFoo $ foo*  should be equal to  *Checked foo []*<br>
> <br>
> Now, if there is a counterexample, I would like to see prettyFoo foo as<br>
> output, folowed by the show of the Errors part.<br>
<br>
It seems you know what property should hold for `parseFoo` and `prettyFoo`.<br>
Per the QuickCheck manual [1] this could be written as<br>
<br>
    import Test.QuickCheck<br>
<br>
    propOnAllFooText :: Property<br>
    propOnAllFooText = forAll (arbitrary :: Gen Foo) $ \exFoo -><br>
        parseFoo (prettyFoo exFoo) == Checked exFoo []<br>
<br>
What you are missing is a way to generate the test cases (the `arbitrary'<br>
generator above). You need a way to declare this instance<br>
<br>
    instance Arbitrary Foo where<br>
        -- arbitrary :: Gen Foo<br>
        arbitrary = <something><br>
<br>
You can see example on how to define it on the manual [1]. Good luck.<br>
<br>
[1]: <a href="http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html" rel="noreferrer" target="_blank">http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html</a><br>
<br>
-- <br>
-- Rubén<br>
-- pgp: 4EE9 28F7 932E F4AD<br>
</blockquote></div>