
6 Feb
2008
6 Feb
'08
8:50 a.m.
On Tue, 5 Feb 2008, Felipe Lessa wrote:
On Feb 5, 2008 6:06 PM, Dan Weston
wrote: Can you do this with a GHC rule? Something like:
{-# RULES "join_dot_fmap_return/id" forall x . join (fmap return x) = x #-}
Dan
I guess this would make use of the rule (otherwise the transformation would change the code's semantic) but would not enforce that the rule itself is valid (which is undecidable).
I have already thought about (ab)using GHC rules for forcing programmers to take care. :-) That is, if the rule would be stated as above, then programmers _have_ to ensure that the law is satisfied, and the optimizer will penalize violations of the rules with non-working code.