Haskell' - class aliases
g9ks157k at acme.softbase.org
Thu Apr 24 16:21:03 EDT 2008
Am Donnerstag, 24. April 2008 21:27 schrieb John Meacham:
> On Thu, Apr 24, 2008 at 08:48:15PM +0200, Wolfgang Jeltsch wrote:
> > I also have some remark: Why not write
> > > class Eq a => Num a = (Additive a, Multiplicative a)
> > instead of
> > > class Num a = Eq a => (Additive a, Multiplicative a)
> Well, because you can think of 'Num a' as an alias for 'Eq a =>
> (Additive a, Multiplicative a)', not that Eq is a superclass of Num
> which the class declaration syntax implies.
Hmm, in what way is Num a an alias for Eq a => (Additive a, Multiplicative a)?
You cannot write this:
> square :: (Eq a => (Additive a, Multiplicative a)) => a -> a
I would say: “Under the condition that Eq a holds, Num a is an alias for
(Additive a, Multiplicative a). And this seems to be perfectly expressed by
my above proposal.
More information about the Haskell-prime