[m-dev.] For review: Add some parametric insts to std_util

Warwick Harvey wharvey at cs.monash.edu.au
Thu Feb 24 14:36:33 AEDT 2000


I wanted a `maybe/1' inst when writing Mercury code for the HAL library, 
realised it didn't exist, figured I'd add it, and did a few more similar 
ones while I was at it.

Warwick


Estimated hours taken: 0.25

library/std_util.m:
        Added parametric instantiations corresponding to the parametric
        types `maybe/1', `maybe_error/1', `pair/2' and `pair/1'.


Index: std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.178
diff -u -r1.178 std_util.m
--- std_util.m  2000/01/19 09:45:18     1.178
+++ std_util.m  2000/02/24 03:30:13
@@ -84,9 +84,11 @@
 % The "maybe" type.

 :- type maybe(T) ---> no ; yes(T).
+:- inst maybe(I) ---> no ; yes(I).

 :- type maybe_error ---> ok ; error(string).
 :- type maybe_error(T) ---> ok(T) ; error(string).
+:- inst maybe_error(I) ---> ok(I) ; error(ground).

 %---------------------------------------------------------------------------
--%

@@ -100,6 +102,8 @@

 :- type pair(T1, T2)   --->    (T1 - T2).
 :- type pair(T)                ==      pair(T,T).
+:- inst pair(I1, I2)   --->    (I1 - I2).
+:- inst pair(I)                ==      pair(I,I).

        % Return the first element of the pair.
 :- pred fst(pair(X,Y)::in, X::out) is det.


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