[mercury-users] some [T] ...

Michael Day mikeday at yeslogic.com
Mon Nov 18 15:22:42 AEDT 2002


> 	:- type abc ---> a ; b ; c.
> 
> 	:- subtype ab < abc ---> a ; b.

By "including those inside typeclass declarations" did you mean that I
could declare the following type class:

:- typeclass foo(T) where [ func foo(T) = string ].

and make ab an instance of it?

:- instance foo(ab).

Or is this primarily aimed at static predicates? (Where it looks very very
useful I must say, particularly for non-empty lists and other quite common
yet unreadable cases).

> 	:- pred q(z(ab), io, io).
> 	:- mode q(in, di, uo) is det.
> 
> becomes
> 
> 	:- pred q(z_rep(abc), io, io) is det.
> 	:- mode q(in(bound(z(Z))), di, uo) is det.

Wow, so does that mean I could have lists and maps and god knows what else
all containing predicates? Is it possible to say:

:- pred q(list(z(ab)), io, io).
:- mode q(in, di, uo) is det.

and everything just works?

Michael (somewhat awestruck by the thought)

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