[mercury-users] Meta programming on exported module items?

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Feb 1 10:10:45 AEDT 2006


On 31 Jan 2006, at 19:26, doug.auclair at logicaltypes.com wrote:

> Dear all,
>
> I'm wondering if Mercury allows metaprogramming or reasoning on 
> exported module items, such as exported predicates/functions.  I see 
> (but do not yet comprehend) the type_desc module (but I am working on 
> understanding this, as there's an interesting paper on the automatic 
> generation of random test data from any arbitrary type in Isabelle 
> (HOL): http://www4.in.tum.de/~nipkow/pubs/sefm04.html -- an useful 
> enhancement to QuickCheck).  But I do not believe the type_desc 
> module, gives, e.g. iteration over all exported items of a module.
>
> I ask because I've created a unit-test-case-generator in Prolog for 
> Prolog programs.  It uses the predicate predicate_property/2 to 
> capture the exported predicates, then it writes test skeletons for all 
> those predicates based on mode analysis.  I would like to do the same 
> thing for the Mercury systems I build -- these skeletons save quite a 
> bit of time in the construction of unit test cases, and it appears 
> that qcheck does not support this (I am speaking out of turn here as I 
> have neither used Haskell's QuickCheck nor Mercury's qcheck ... I'm 
> looking forward to using this system).
>

I don't believe you can iterate over all exported module items 
programmatically.  You can decompose a type into it's functor and 
argument types, so you could generate random terms of a given type (see 
the deconstruct predicate), but you can't get access to a list of all 
the exported types and preds of a module.

It is possible to access all the (export or private) predicates and 
types in a module in the debug grades, but from the debugger, not from 
within the compiled program.  The decldebug grade also has a compact 
representation of the body of each predicate that contains mode 
information.  I have thought about extending the debugger with 
automatic test case generation capabilities, but I'm not sure when I'll 
get round to it.

Another option is to add a compiler option that causes the compiler to 
produce random test cases for the code it compiles (since the compiler 
has access to all the necessary info).

Ian.

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list