Simon Peyton-Jones wrote:
> Aha. I have a good answer to that! Use:
>
> {-# RULES
> "fromIntegral/Int8->Int16" fromIntegral = int8ToInt16
> #-}
> [...]
Cool, exactly what I (and the Int/Word modules) need! But this should
better be documented in the User's Guide. A few remarks:
* Putting the signature into the rule name seems a little bit
strange, e.g. "fromIntegral/Int8->Int16" vs "foldr/build".
* Has `"foobar/Int8->Int16" fromIntegral = int8ToInt16' the same
effect?
* There's a typo in the User's Guide:
"map/map" forall f,g,xs. map f (map g) xs = map (f.g) xs
should probably read:
"map/map" forall f,g,xs. map f (map g xs) = map (f.g) xs
* I don't fully understand the following quote from the docs:
"A pattern variable may optionally have a type signature. If
its type is polymorphic, it must have a type signature."
Why does "map/map" *not* need a type signature, but "foldr/build"
does? f, g, and xs are all polymorphic.
* What happens when more than one rule matches? Warning? Error?
Sound of silence? :-)
Cheers,
Sven
--
Sven Panne Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen Oettingenstr. 67
mailto:[EMAIL PROTECTED] D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne