The exemplar idea is attractive, especially since it's idiomatic in Factor.
However, an exemplar of 1 may not be precise enough for certain predicates.
How can we define sufficiently specific exemplars for predicates like
non-negative? positive? divides-by-three? byte? char? lowercase char? vowel?
I imagine classes could reduce the ambiguity of exemplars. How much
boilerplate would be required to make classes for the above? <non-negative>,
<positive>, <divides-by-three>, <byte>?
It's starting to look circular: How can we define legal inputs for a
predicate in order to test whether the predicate is succeeds for all legal
inputs?
A conceptually easy solution is to make quotations that generate the desired
input, slap 'em in an array, and call predicate { generators ... }
forall100 times. I'm just not sure how to do call(function, arguments)
in factor.
Cheers,
Andrew Pennebaker
www.yellosoft.us
On Thu, Aug 25, 2011 at 12:22 AM, Joe Groff <arc...@gmail.com> wrote:
>
> On Aug 24, 2011, at 8:44 PM, Andrew Pennebaker wrote:
>
> Aye, it's a bit awkward, but I know that Haskell can do it because that's
> how Haskell's QuickCheck library works. It even goes one step further and
> creates the appropriate list of value generators according to the
> predicate's type.
>
>
> Perhaps you could do something similar in Factor. Instead of using
> generator functions, you could make a single generic function that lets
> types describe how to generate arbitrary members of themselves:
>
> GENERIC: something-like ( exemplar -- arbitrary )
>
> ERROR: don't-know-how-to-make-something-like exemplar ;
>
> M: object something-like
> don't-know-how-to-make-something-like ;
>
> M: integer something-like
> 2 64 ^ random ;
>
> M: float something-like
> -1.0 1.0 uniform-random-float ;
>
> Then pass an exemplar of the type to something-like:
>
> ( scratchpad ) 1 something-like .
> 16789018172707
>
> ( scratchpad ) 1.0 something-like .
> -0.13980920020477
>
> Union types and tuple types could then naturally implement something-like
> in terms of their constituent types.
>
> -Joe
>
>
> ------------------------------------------------------------------------------
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management
> Up to 160% more powerful than alternatives and 25% more efficient.
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk