[Haskell-cafe] Using Template Haskell to automate QuickCheck
byorgey at gmail.com
Wed Jun 20 21:38:02 EDT 2007
(I originally tried to send this on Jun 8, but it seems that due to various
issues it did not actually get sent over the list. Apologies if anyone gets
Following some recent discussions in #haskell, I've decided to try my
hand at a module to allow automation of QuickCheck testing. I'm
aware that there are already various "homegrown" solutions out there,
(e.g. ,) as well as idiomatic boilerplate to do this (e.g. ),
but it feels like there ought to be a more elegant/DRY-style solution.
In my ideal vision, you'd be able to do something like this:
import Test.AutoQuickCheck -- the library module I want to write
prop_foo = blah -- some QuickCheck tests
prop_bar = blah blah
main = $(runChecks)
...where runChecks would use TH to reflect on the current module, find
any top-level function declarations beginning with "prop_", and
generate code to run them all through QuickCheck, printing the
results. I think the attractions of such a system (if it could
actually work) should be obvious.
However, after reading all about TH it doesn't seem like there's a way
to do this (reflecting on the current module to pull out the names of
certain top-level declarations). Since I don't know much about how TH
is implemented, I'm not sure whether (1) there's a good reason this is
pretty much impossible with TH; (2) it would be possible but it's
currently unimplemented; or (3) there actually is a way to do what I
want, but I'm not clever enough in the ways of TH to figure it out.
(Or (4) none of the above?)
Any thoughts or advice would be greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe