[mercury-users] io__error

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Aug 1 12:05:59 AEST 2002

On 01-Aug-2002, Michael Day <mikeday at yeslogic.com> wrote:
> > Maybe you mean providing a constructor function to
> > allow users to construct their own values of type `io__error'?
> > That might be useful.
> This would be good, as it would allow user functions to return io__res,
> rather than creating a new result type every time.

Creating a new result type every time is pretty trivial, IMHO.
So this really doesn't buy you all that much.

However, if you think it is worthwhile, feel free to post a patch for
this to <mercury-reviews at cs.mu.oz.au>...

> > 	:- type io__res(T) --->
> > 			ok(T)
> > 		;	some [E] error(E) <= err_msg(E).
> > 
> > then this is basically equivalent to just using `string' instead of
> > `io__error' -- again this would fail to meet the design goal of
> > being extensible in a backwards-compatible way.
> You could add methods to the typeclass without disturbing existing code
> that only called err_msg, couldn't you?

Yes, but adding new methods to the typeclass would break any existing
code which constructed error/1 values of type io__res/1, in such a way
that there would be no good clean fix.  (Defining stub methods that
just throw exceptions would *not* be a good fix.)
So code that called err_msg would, after the type class was extended,
only work with error/1 values constructed from io__errors.
In other words it would achieve no more reusability than you
already get today with io__error_message.

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