[mercury-users] discriminant types, generators
Matthias Kretschmer
mccratch at gmx.net
Mon Jul 14 01:00:17 AEST 2003
Hello!
I have the following problem, want to do the following task:
having some discriminant type, say
:- type mytype ---> a ; b ; c ; d.
maybe used by some other type, say
:- type othertype ---> someint(int) ; intandmytype(int, mytype).
Now I want to define some predicate that can be used to generate a list
of intandmytype(2, X) for all X in mytype.
I thought of something like this:
:- pred mypred(othertype).
:- mode mypred(out) is multi.
mypred(someint(2, _)).
and using solutions/2 from std_util for generating a list using mypred.
but the compiler complains about a mode error. The only solution I come
up with, was some extra predicate, lets say
:- pred is_mytype(mytype).
:- pred is_mytype(out) is multi.
is_mytype(a). is_mytype(b). is_mytype(c). is_mytype(d).
but I don't really like to have to do this this way. Is there any other
solution?
--
Greetings
Matthias Kretschmer
--------------------------------------------------------------------------
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