[m-rev.] for review: move same_type and find_functor to interface

Ondrej Bojar bojar at csse.unimelb.edu.au
Mon Sep 24 16:31:28 AEST 2007


Estimated hours taken: 0
Branch: main

library/term.m:
     Move same_type/2 and find_functor/5 to interface. Both are useful in custom
     pickling and unpickling predicates.

Index: library/term.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/term.m,v
retrieving revision 1.127
diff -u -r1.127 term.m
--- library/term.m	13 Feb 2007 01:58:54 -0000	1.127
+++ library/term.m	24 Sep 2007 06:25:46 -0000
@@ -128,6 +128,16 @@
  :- func univ_to_term(univ) = term(_).
  :- pred univ_to_term(univ::in, term(_)::out) is det.

+    % Given a type descriptor, a functor name and arity, finds the functor
+    % index and the types of its arguments.
+    %
+:- pred find_functor(type_desc::in, string::in, int::in,
+    int::out, list(type_desc.type_desc)::out) is semidet.
+
+    % Ensures type identity of the two arguments.
+    %
+:- pred same_type(T::unused, T::unused) is det.
+
  %-----------------------------------------------------------------------------%

      % vars(Term, Vars):
@@ -647,9 +657,6 @@
          Result = error(Error)
      ).

-:- pred find_functor(type_desc::in, string::in, int::in,
-    int::out, list(type_desc.type_desc)::out) is semidet.
-
  find_functor(Type, Functor, Arity, FunctorNumber, ArgTypes) :-
      N = construct.num_functors(Type),
      find_functor_2(Type, Functor, Arity, N, FunctorNumber, ArgTypes).
@@ -752,8 +759,6 @@
      array.to_list(Array, List),
      type_to_term(List, ArgsTerm).

-:- pred same_type(T::unused, T::unused) is det.
-
  same_type(_, _).

  :- pred univ_list_to_term_list(list(univ)::in, list(term(T))::out) is det.

-- 
Ondrej Bojar (mailto:obo at cuni.cz / bojar at ufal.mff.cuni.cz)
http://www.cuni.cz/~obo
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list