[I'm taking the liberty of broadening this to the Haskell
mailing list. I doubt anyone is on glasgow-haskell-users, where
it started, but not on the haskell list.]
> > I think this has been discussed before, but I've just run into it myself.
> > I have a MPC 'Set', in the usual bog-standard fashion, and I want to
> > define interval arithmetic over sequences of such sets. This requires
> > they also be partially ordered, and of a numeric type themselves, so
> > I end up with something like:
> >
> >
> > instance (Set s n, Num (s n), POrd (s n)) => Num [s n] where
> > n + m
> > = bigunion [ overlaps [n1 + m1 | m1 <- m] | n1 <- n]
> >
> >
> > This works in 3.01, but not in 3.02. Is this restriction a sensible
> > one? Come to that, are my classes? It seems to me that the nature of
> > the MPC forces me to use non-variable contexts, which I think looks
> > a bit uglky, but I don't know of another way to get the same effect.
>
> I'd like to support Alex here: it is absolutely necessary to relax
> condition 10 of SPJ's list.
http://www.dcs.gla.ac.uk/~simonpj/multi-param.html
> Idioms like the one above (`Ord (s a)' or
> `Show (s a)') arise too often and are completely natural.
One of the great merits of imposing restrictions is that
you hear about when they are irritating :-). (The reverse does
not hold.) Examples like this are jolly useful.
Alex: can you flesh out your example any more? I was expecting
Num (s n) not Num [s n], for example.
Ralf: can you supply other examples?
Ditto others.
One possible choice would be to insist that the context of
an instance decl constrained only proper sub-expressions of
the type on the RHS. Alex's example would be fine then, but
perhaps others might not?
Simon