[m-dev.] existentially typed mode/language specific clauses

Simon Taylor stayl at cs.mu.OZ.AU
Tue Jan 29 05:46:52 AEDT 2002


Hi,

I've been trying to make the `.opt' files grade independent
in the presence of foreign code, and I've run into a problem.
The typechecker doesn't allow existentially typed predicates
like the ones below (it gives errors like "variable `U' has
type `U', expected type was `U'.").

In the cases I'm trying to deal with, the different clauses are 
written in different languages (see library/rtti_implementation.m).
At the moment, the foreign clauses which will be used in the current
compilation are selected by make_hlds, avoiding the problem. I'm
trying to delay the clause selection until after the `.opt' file
is written (after typechecking).

Any ideas on how best to fix this?

Simon.


:- module exist_type.

:- interface.

:- some [T] pred p(int, T).
:- mode p(in(bound(1)), out) is det.
:- mode p(in, out) is det.

:- some [U] pred r(int, T, U).
:- mode r(in(bound(1)), in, out) is det.
:- mode r(in, in, out) is det.

:- implementation.

:- import_module int.

:- pragma promise_pure(p/2).
p(_ :: in(bound(1)), q(2) :: out).
p(X :: in, q(X + 1) :: out).

:- some [T] func q(int) = T.
q(X) = X.

:- pragma foreign_proc("C", r(_Int::in(bound(1)), T::in, U::out),
		[will_not_call_mercury, promise_pure],
"
	U = T;
	TypeInfo_for_U = TypeInfo_for_T;
").
:- pragma foreign_proc("C", r(_Int::in, T::in, U::out),
		[will_not_call_mercury, promise_pure],
"
	U = T;
	TypeInfo_for_U = TypeInfo_for_T;
").

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list