[mercury-users] "some" and existential types
Michael Day
mikeday at corplink.com.au
Sat Oct 2 09:21:19 AEST 1999
> Yes, strictly speaking, the `some' is not necessary;
> for cases involving type class constraints, the direction of the
> arrow(s) would be sufficient information for the compiler to infer
> which types were existentially quantified.
So for those cases with typeclass constraints, theoretically at least the
"some" could be optional, just as "all" is...
> Furthermore, the direction of the arrow(s) doesn't help in the case
> where there are no type class constraints involved, because
> in that case there are no arrows for the compiler to look at.
I'm a little confused about this part. What exactly is the difference
between these two declarations:
:- pred give_me_a_value1(T::out).
:- some [T] pred give_me_a_value2(T::out).
If the first declaration has an implicit "all", that would seem to imply
it can return any type at all. The second declaration has an explicit
"some", which seems to imply it returns a particular subset of the
available types? Does the compiler generate different code for these two
cases, do they actually have a substantially different meaning?
Pardon my clumsy attempts to understand this topic, but *cough* thanks to
C++ I'm not used to things having polymorphic return types :(
One final question, which of the following is appropriate:
:- pred transform1(T::in, T::out) <= object(T).
:- pred transform2(T::in, T::out) => object(T).
:- pred transform3(T::in, T::out) <= object(T) => object(T).
Thanks for attacking the clouds of my befuddlement,
Michael
--------------------------------------------------------------------------
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