Actually, the two 'b's aren't the same, as you will see if you use -dppr-debug, or if you look at the .hi file. So the typing for the rule looks right to me. If it isn't matching when you think it should, it must be for some other reason. (Do you agree?)
Perhaps -ddump-rules should 'tidy' the rule so that it doesn't print variables that look the same but arent. Simon | -----Original Message----- | From: Josef Svenningsson [mailto:[EMAIL PROTECTED]] | Sent: 20 February 2002 17:01 | To: [EMAIL PROTECTED] | Subject: Typing RULES | | | Hi! | | Ghc seems to have some problems in inferring the most general | types of RULES pragmas. The bug was not present in 5.02.1 but | shows up in a cvs version checked out yesterday. | | Here's the problem: | Consider the following example from the user's guide: | | {-# RULES | "map/map" forall f g xs. map f (map g xs) = map (f.g) xs #-} | | When I compile with -ddump-rules I get the following rule: | | "map/map" __forall {@ b | @ b | @ a | f :: (b -> b) | g :: (a -> b) | xs :: [a]} | GHC.Base.map @ b @ b f (GHC.Base.map @ a @ b g xs) | = GHC.Base.map @ a @ b (GHC.Base.. @ b @ b @ a f g) xs ; | | (And it also turns out this rule is listed among the imported | rules, not the local ones, which is a bit confusing.) | | The rule says that f must have type b -> b for some b. This | is clearly Bad as the matching algorithm also matches types | and the rule will not be fired in all the cases it should. | | When I add a type signature for f then g get type b -> b. In | order to get the desired behaviour I have to add type | signatures to both f and g. | | I hope this is easy to fix. | | Cheers, | | /Josef | | PS. Would it be possible to add a -fwarn-pragma which warns | when a pragma is ignored? It is quite frustrating when some | rules are silently ignored and you keep wonder why the rules | don't fire. I guess I've learnt to use -ddump-rule the hard way... | | _______________________________________________ | Glasgow-haskell-bugs mailing list | [EMAIL PROTECTED] | http://www.haskell.org/mailman/listinfo/glasgow-| haskell-bugs | _______________________________________________ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
