[m-dev.] file streams

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 28 13:10:05 AEDT 1999


On 27-Dec-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> 
> > From: Michael Day [mailto:mcda at cat.cs.mu.OZ.AU]
> > 
> > :- type file__duplex.
> > :- instance stream__stream(file__duplex).
> > :- instance stream__input(file__duplex).
> > :- instance stream__output(file__duplex).
> > :- instance stream__duplex(file__duplex).
> > :- instance stream__seekable(file__duplex).
> 
> Isn't `instance stream__duplex' implied by 
> `instance stream__{in,out}put'?  Or is the
> declaration necessary?

No, the declaration is necessary.  Even if a type class has no
methods of its own, you need to an explicit instance declaration
for each type that is an instance of that typeclass.
After all, in general there might be semantics (e.g. additional
axioms) associated with membership in a type class.  Possessing
definitions for all the methods doesn't necessarily guarantee
that a type's semantics are correct for membership in a given
type class.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list