while optimizing? (Was: RULES for
SPECIALIZ(E)ations)
|
| An even simpler example, with just one module:
|
| ---
| module Test where
|
| import Data.List (genericLength)
|
| {-# RULES
| genericLength/length genericLength = length
An even simpler example, with just one module:
---
module Test where
import Data.List (genericLength)
{-# RULES
genericLength/length genericLength = length
#-}
---
D:\...\hask
But I'm getting an error on recompilations that I don't understand. It
happens only with -O (or -On), AFAICS.
On second (and less sleepy) thought, there's no mystery in it happening
only with -O, as RULEs aren't used for non-optimizing compilations :)
Still, it's weird to get an error on
|
| I suppose I'm being bitten by User's Guide 7.8.2:
|
| If more than one rule matches a call, GHC will choose one
arbitrarily
| to apply.
|
| even if a bit later it says:
|
| So a rule only matches if the types match too.
|
| Am I understanding right and it's that so?
I think so.
I'm playing with rules, and I wonder if it is posible to define a rule
that will trigger for a specialization of a function.
(In the following examples, the functions are not necesarily useful or
good-style... :)
I have:
count :: (Integral b) = (a - Bool) - [a] - b
count = count' 0