[mercury-users] Type Classes

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Oct 12 00:59:25 AEST 2002


On 11-Oct-2002, Noel  Pinto <cool4life at rediffmail.com> wrote:
> I have a query regarding Type classes.
> 
> I want to know how to use type classes. I have tried writing the
> code by looking at the example in the manuals, but still it 
> gives me errors.

Type classes can be used for cases where you would like a single interface
that you want to implement in different ways for different types.

> I want to write a code to take a number, square it and display 
> it on the screen.

It's not clear why you would want to use type classes for this.
Type classes generally only make sense when you have, well,
at least two types that you want to do something similar with.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  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