To my
>> 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]
Simon P. Jones responds
> [..]
> I rather doubt that rules will help you here. Type casting
> is the business of the type checker, not an optimiser [..]
> [..]
> 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
> want I guess.
> [..]
Why? This rule contains the x::a, y::[a] condition,
so 1+1 does not fit the rule, and 1+[1] does.
Someone else (sorry! lost the letter) also remarks that x+y is ill-
typed, and so, the question is wrong.
No. The idea was to use *rules* to convert types *before* the final
type check. Change of type language by means of user defined rules.
For example, here, x casts from Num a => a to Num a => [a].
Probably, the rule, should look differently.
The subject is dim to me, though ... maybe, wrong idea.
------------------
Sergey Mechveliani
[EMAIL PROTECTED]