To my early reply
: As to `instance D a',
: it is not a loss. Because `instance D a' is the same as
: `class D a' - supplied with the default definition. For example,
: the illegal declaration pair
: class C a => D a where d :: a -> a
: instance C a => D a where d = <definition>
:
: can be replaced with the legal and simpler declaration
:
: class C a => D a where d :: a -> a
: d = <definition>
Christian Sievers <[EMAIL PROTECTED]>
writes
> ...
> It does not actually give any instance of D.
> You have to declare all of them seperately, and you would rather want
> to just say instance C a => D a but you can't.
> ...
-------------------------------------------------------------------
Thank you very much. Indeed, for the program
class Eq a => D a where d :: a -> a -> Bool
d = (==)
main = putStr (shows (d 'a' 'b') "")
ghc reports there is no instance of D for Char !
If we add instance D Char
the program starts to work as I expected.
But, well, is this a natural behaviour for the language?
The above default declaration of `d' expresses clearly the
dependence between the instances. As soon as the Eq instance
appeares for the type <T>, it should induce the D instance with the
given value for `d', should it?
Apart from this questions, you have referred earlier to a good
example
class Dual a where dual :: a -> a
instance Num a => Dual a where dual = negate
Suppose Haskell agrees with my treating of the default class
declaration. Still declaring of Num as a superclass of Dual would not
help much. Because this conflicts with the standard Prelude, and
generally, with separate compilation. It is better to improve the
`instance' treating.
------------------
Sergey Mechveliani
[EMAIL PROTECTED]