"read: no parse" with functionShow
Nick Smallbone
nick.smallbone at gmail.com
Tue Jul 24 15:14:10 BST 2012
Hi Brent,
On 24 July 2012 14:19, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
>> Do you also shrink the functions in your Arbitrary instance? Shrinking
>> is what turns the function into a finite, showable function, and also
>> what turns it into a total function in this case.
>
> No, I haven't overridden the definition of shrink in any of my custom
> Arbitrary instances. The only shrinks that are getting called are
> ones in instances defined by QuickCheck.
Ah, this would be the problem. You need to keep the [a :-> Bool]
(rather than just the [a -> Bool]) around somewhere and shrink it in
your Arbitrary instance. I'm not sure what's the best way to do this -
perhaps define a type along the lines of
data QCSplitter a = QCSplitter [a :-> Bool] ([a :-> Bool] -> Splitter a)
with its own Arbitrary instance (complete with shrink function) and
quantify over this instead of Splitter, although I appreciate this
isn't ideal.
Nick
More information about the QuickCheck
mailing list