Fri, 12 May 2000 11:47:11 -0600 (MDT), Thomas Harke <[EMAIL PROTECTED]> pisze:

> Why is it that type synonyms can't be made class instances?

It does not add any functionality (see below), and could be confusing
because it would really make the instance for the expansion of the
type synonym (with "type Z = Integer" it is indistinguislable where
you mean to use Integer or Z, so they must share instances - it is
the same type, only spelled differently).

GHC developers decided that it is more convenient than confusing and
permitted to spell type synonyms in instance definitions. I agree
with it.

> The reason I ask is that I'm finding that definitions for monads are
> obfuscated by the need for constructors and field accessors, whereas
> if type synonyms could be instances the code would be much cleared.

You don't ask for instances for type synonyms; you ask for partial
application of type synonyms.

It is indeed not permitted, and AFAIK even if it would have well
defined semantics it would make the type system undecidable.

In GHC you can use type synonyms in instance definitions, but you
must apply them to all arguments, as always, so it does not help with
the problem.

I don't know any better solution than using newtypes. You can use
generic monads defined by others, e.g. those in GHC's modules, which
have already done the dirty work.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-


Reply via email to