[mercury-users] Typeclass constraint on type declaration

Vladimir Gubarkov xonixx at gmail.com
Mon Feb 7 12:11:22 AEDT 2011


Hi, dear ALL

I've found some thead about that (dated 1999)

http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.9905/0034.html

But despite the statement of usefullness of this feature:

http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.9905/0046.html

Seems, it's still not implemented.

I've wrote simple piece of code:

:- module tc1.

:- interface.

:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.

:- import_module int.

:- typeclass a(T) where [
func aaa(T) = T
].

:- instance a(int) where [
aaa(E) = E
].

:- type q(T) ---> q(T) <= a(T).

:- func z(q(T)) = T.
z(q(T)) = aaa(T).

main --> print(z(q(123))).

As you can see, it fails to compile:

D:\TEST\mercury>mmc.bat --make --infer-all tc1
Making Mercury\ints\tc1.int
tc1.m:021: In definition of type `tc1.q'/1:
tc1.m:021:   error: undefined type `a'/1.
`Mercury\ints\tc1.int' not written.
** Error making `Mercury\ints\tc1.int'.


Have you considered this feature useless/hard to implement?


Sincerely yours,
Vladimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20110207/a18fd2f4/attachment.html>


More information about the users mailing list