Haskell' - class aliases
John Meacham
john at repetae.net
Fri Apr 25 19:51:35 EDT 2008
On Thu, Apr 24, 2008 at 10:21:03PM +0200, Wolfgang Jeltsch wrote:
> 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.
Hmm... I guess it depends on how you think about it. I tend to think
about them in terms of what they are rewritten to rather than a
proposition about classes. but perhaps that makes more sense. Will mull
on it some..
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-prime
mailing list