> class (Ring r,AddGroup (m r)) => RightModule m r
> where
> cMul :: m r -> r -> m r
> -- "vector" (m r) multiplied by "coefficient" r'
>
> Haskell rejects this (m r) in the context. Could Haskell-2 allow it?
Yes. See http://www.dcs.gla.ac.uk/~simonpj/multi-param.html
> instance Ring r => RightModule r r where cMul = mul
>
> Haskell rejects this `=> RightModule r r'
This is fine too (for Haskell 2). See the same URL.
> `newtype' cannot derive all the instances automatically.
>
> Thus, in our case, add (Id 1) (Id 2) is illegal.
>
> This may occur a stupid question, but
> why Haskell allows the `newtype' derivation only for the standard
> classes?
> Why not support declarations like
>
> newtype N a b = N (T a b) deriving(Eq,Ord,AddGroup,Ring)
> or newtype N a b = N (T a b) deriving( all )
That would indeed be possible for newtype; but my guess is
that if you want 'all' then you ought to be able to get away without
a newtype at all. But I might well be wrong about this.
Anyway, it's not an unreasonable suggestion.
Simon