Simon Peyton-Jones wrote:
> 
> > Another question on *rules*.
> > Could they help the implicit type casting?
> > For example, with
> >                           {rules Num a=> x::a, y::[a] ==> x+y = [x]+y}
> >                           instance Num a => Num [a] where ...
> > one could expect for  x :: Num b=>b  the casting
> >                                              x + [x,y] --> [x] + [x,y]
> >
> 
> Provided the two sides of the rules have the same overall type,
> GHC will be happy.  But since there are no side condition, your
> rule will rewrite *every* x+y to [x]+y, which isn't what you

every x+y that x::a & y::[a], in which case plain x+y doesn't make sense
anyway.

> want I guess.

[..]

> Simon

Cheers, Otgonbayar


Reply via email to