[mercury-users] io__error

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Aug 1 11:28:31 AEST 2002


On 01-Aug-2002, Michael Day <mikeday at yeslogic.com> wrote:
> 
> > The rationale for this design is that it allows future Mercury
> > implementations to provide more information about the kind of error,
> > without needing to change the interface of procedures which return
> > an io__res(T).
> 
> Then what about making io__error more public,

I don't know what you mean by that.

If you mean making it a concrete type rather than
an abstract type, then that would defeat the purpose
of introducing it in the first place -- it would
fail to meet the design goal of being extensible
in a backwards-compatible way, that I explained above.

Maybe you mean providing a constructor function to
allow users to construct their own values of type `io__error'?
That might be useful.

> or making it an instance of
> a typeclass with an error_message function, so that the various result
> types can be used in other situations, with other error types?

Making io__error an instance of such a type class would be fine,
but I don't see how it would help.  Note that you can do this
in your own code -- the type class need not be part of the
standard library.

If you mean changing io__res so that it used an existentially
qualified type, e.g.

	:- typeclass err_msg(E) where [
		func msg(E) = string
	].

	:- 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.

-- 
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