[mercury-users] Thanks, and a concrete question

Keith Braithwaite keith at keithbraithwaite.demon.co.uk
Tue Jun 3 05:51:16 AEST 2003


Many thanks for the earlier comments on my code. I've a definite 
question new about instantiatedness.

I'd like to use ++ to roll test suites together. So I've introduced 
this to my testing module
:- func named_suite ++ named_suite = named_suite.  %interface
S1 ++ S2 = suite_append(S1, S2).   %implementation

:- func suite_append( named_suite, named_suite) = named_suite.
:- mode suite_append(in,in) = out is det.

:- import_module string.

suite_append(
	named_suite(Name1,Tests1),
	named_suite(Name2,Tests2)) =
	named_suite(Name3,Tests3) :-
	Name3 = Name1 ++ " then " ++ Name2,
	list__append(Tests1,Tests2,Tests3).	

This seems to be working, since this test passes.
:- pred test_suite_concatenation is semidet.
test_suite_concatenation :-
	Example_suite1 = named_suite("suite1", []),
	Example_suite2 = named_suite("suite2", []),
	Suite = Example_suite1 ++ Example_suite2,
	Suite ^ name = "suite1 then suite2",
	Suite ^ tests = (Example_suite1 ^ tests) ++ (Example_suite2 ^ tests).

that's when running my two test suites like this:
main(!IO) :-
	run_tests(mtest_tests__suite,!IO),
	run_tests(gotests__suite,!IO).

However, when I change to this
main(!IO) :-
	run_tests(mtest_tests__suite ++ gotests__suite,!IO).

The compiler complains that
test.m:016: In clause for `main(di, uo)':
test.m:016:   in argument 1 of call to predicate `mtest:run_tests/3':
test.m:016:   mode error: variable `V_7' has instantiatedness `ground',
test.m:016:   expected instantiatedness was 
`bound(mtest:named_suite(ground, bound([] ; '[|]'((mtest:case), 
list:list_skel((mtest:case))))))'.

Which I don't understand. How does an out argument from a function that 
doesn't fail (it's det, right?) be "ground"? What am I missing?

Advice please,
Keith

--------------------------------------------------------------------------
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