On 28-May-1998, Adrian Hey <[EMAIL PROTECTED]> wrote:
> > A strong type system is supposed to prevent runtime errors.
> > Thus it makes sense to disallow anything that might
> > result in an attempt to access an unbound type.
>
> Yes, but in the cases we've been talking about we know that there will be
> no access to the unbound type since the reason the type is unbound is that
> it isn't referenced by expressions such as (Right something).
That does not imply that the type won't be used.
As shown in my example program, the type may be used for method
dispatch, even if there aren't any instances of the type (i.e.
values which have that type) around.
> > > as a general rule, I completely disregard Haskell's class system when ever
> > > possible. If this makes me a naive user, then I must plead guilty.
> >
> > You shouldn't disregard it "when ever possible";
> > you should only disregard it in cases where you will
> > often want to apply different methods to the same data type.
>
> I know using Haskell Classes will probably result in neater code a lot of
> the time. But when I write modules I like to think that they will last
> me 'forever', so I try to make them as general purpose as possible in the
> hope that they might come in handy again some day. Given the choice between
> a neat but non-general way of doing things and a messy but general way I
> am always inclined towards the latter.
Ah, but the type class method is general.
It's just a question of where you put the messiness.
With type classes, the common case is elegant, but things
get messy (you have to use newtype, etc.) if you want to
use operations other than the default for the type.
With the alternatives that you are advocating, using
different operations is elegant, but things are a little
messy (you have to pass stuff explicitly) in the common case.
> > > I suppose I could probably get around this problem by by making different
> > > types using newtype, but I this would no doubt cause other complications
> > > elsewhere.
> >
> > Yes, perhaps. See Alistair Reid's proposal for newtype typecasts
> > to avoid some of these complications.
>
> I think I've seen this. It didn't seem to go down to well if my memory
> is correct.
True, but maybe considerations such as these will sway the balance a bit! ;-)
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.