<div>I think you're looking for something like this:<br><br>```<br>prop_parser :: Foo -> Property<br>prop_parser foo  =<br>   case parserFoo pretty of<br>      Checked foo' [] | foo == foo' -> property True<br>      a  -> counterexample (show a ++ "\n" ++ show pretty) False<br>  where<br>    pretty = prettyFoo foo<br>```<br></div><div><br></div><div class="protonmail_signature_block"><div class="protonmail_signature_block-user protonmail_signature_block-empty"></div><div class="protonmail_signature_block-proton">Sent with <a href="https://protonmail.com/" target="_blank">ProtonMail</a> Secure Email.</div></div><div><br></div><div class="protonmail_quote">
        ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br>
        On Saturday, June 12th, 2021 at 12:49, Han Joosten <han.joosten.han@gmail.com> wrote:<br>
        <blockquote class="protonmail_quote" type="cite">
            <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">Op vr 11 jun. 2021 om 23:31 schreef Ruben Astudillo <<a href="mailto:ruben.astud@gmail.com" rel="noreferrer nofollow noopener">ruben.astud@gmail.com</a>>:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">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 target="_blank" rel="noreferrer nofollow noopener" href="http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html">http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html</a><br>
<br>
-- <br>
-- Rubén<br>
-- pgp: 4EE9 28F7 932E F4AD<br>
</blockquote></div>

        </blockquote><br>
    </div>