[mercury-users] Typeclass constraint on type declaration

Vladimir Gubarkov xonixx at gmail.com
Fri Feb 11 00:29:57 AEDT 2011


Thanks Julien for your reply.

I played a little with this and found that we can create typeclass
constraints on a type in case that we use existential types, such that we
can get working code roughly equivalent of my first 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+1
].

:- type q ---> some [T] q(T) => a(T).

z(q(T)) = aaa(T).

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

===

$ tc1
124

Now my question is: are the two approaches REALLY equivalent? Or should the
(not yet implemented) approuch give us some fundamentally new means in
programming with mercury?


Thank you.

On Thu, Feb 10, 2011 at 8:40 AM, Julien Fischer <
juliensf at csse.unimelb.edu.au> wrote:

>
> Hi,
>
> On Mon, 7 Feb 2011, Vladimir Gubarkov wrote:
>
> ...
>
>
>  Have you considered this feature useless/hard to implement?
>>
>
> Neither; it's just this particular feature is not very high on the list
> of features to implement given the amount of developer time available.
>
> Julien.
> --------------------------------------------------------------------------
> mercury-users mailing list
> Post messages to:       mercury-users at csse.unimelb.edu.au
> Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
> Subscriptions:          mercury-users-request at csse.unimelb.edu.au
> --------------------------------------------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20110210/30509356/attachment.html>


More information about the users mailing list