[m-dev.] for review: add support for existential types [3/4]

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 9 04:04:22 AEST 1998


On 09-Jul-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > Can we see the diff for that bit?
> 
> Yes -- but not until I've written it! ;-)

Turned out to be much easier than I thought it would be.

--- backup/prog_io.m	Wed Jul  8 06:30:58 1998
+++ prog_io.m	Thu Jul  9 04:00:35 1998
@@ -1039,15 +1039,19 @@
 		constraints(exist, Constraints), Decl).
 parse_decl_attribute("some", [TVars, Decl],
 		quantifier(exist, TVarsList), Decl) :-
-	% XXX we should check that `TVars' is of the
-	%     appropriate form (i.e. a list of variables)
-	term__vars(TVars, TVarsList).
+	parse_list_of_vars(TVars, TVarsList).
 parse_decl_attribute("all", [TVars, Decl],
 		quantifier(univ, TVarsList), Decl) :-
-	% XXX we should check that `TVars' is of the
-	%     appropriate form (i.e. a list of variables)
-	term__vars(TVars, TVarsList).
+	parse_list_of_vars(TVars, TVarsList).
+
+:- pred parse_list_of_vars(term, list(var)).
+:- mode parse_list_of_vars(in, out) is semidet.
 	
+parse_list_of_vars(term__functor(term__atom("[]"), [], _), []).
+parse_list_of_vars(term__functor(term__atom("."), [Head, Tail], _), [V|Vs]) :-
+	Head = term__variable(V),
+	parse_list_of_vars(Tail, Vs).
+
 :- pred check_no_attributes(maybe1(item), decl_attrs, maybe1(item)).
 :- mode check_no_attributes(in, in, out) is det.
 
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list