[Haskell-cafe] GHC optimisations
ndmitchell at gmail.com
Wed Aug 22 04:43:32 EDT 2007
> Other rules that could be interesting are:
> > forall a b. fromInteger a + fromInteger b = fromInteger (a + b)
> > forall a b. fromInteger a * fromInteger b = fromInteger (a * b)
This is wrong, since the class function can do what it wants. Imagine:
instance Num String where
(+) = (++)
fromInteger x = show x
1 + 2 :: String
this expression now goes from "12" to "3" by applying this rule.
You need to be incredibly careful if there are any classes floating around.
More information about the Haskell-Cafe