[mercury-users] Newbie questions about typeclasses

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Apr 25 02:40:26 AEST 2001


On 24-Apr-2001, Critterrathman at aol.com <Critterrathman at aol.com> wrote:
> Ok.  I'm good to go with the problems I had.  One additional question I have 
> concerns the write accessors.  In my example, the read accessors work fine in 
> the form of:
> 
>    getX_Circle(This) = This^x.
> 
> I gather also that there is a write form of the accessor using the ':=' for 
> the assignment but I can't figure out how to use it.  Currently I'm writing 
> it as:
> 
>    setX_Circle(circleRecord(_,Y,Radius), X) = circleRecord(X, Y, Radius).
> 
> which spins off a new record based on the values in the input record.  
> Anyhow, is there a way to use the set accessor to make this shorter, if not 
> more efficient?

Yes:

    setX_Circle(Circle, X) = Circle^x := X.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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