[mercury-users] invalid universal quantification example confuses me

Terrence Brannon tmbranno at oracle.com
Fri Jul 6 15:51:28 AEST 2001


The manual does state:

  If a type variable in the type declaration for a polymorphic predicate
  or function is universally quantified, this means the caller will
  determine the value of the type variable, and the callee must be
  defined so that it will work for all types which are an instance of
  its declared type. 



:- pred foo(T).
foo(_).
% ok


:- pred bad_foo(T).
bad_foo(42).
% type error

But I don't see why the second case causes a type error:
1 - we are dealing with a predicate that is universally quantified
2 - therefore the caller (in this case bad_foo(42)) determines the
    type of the type variable
3 - the callee doesn't seem to have any problem dealing with values of
    type int
 

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