
Hello Simon, Wednesday, February 08, 2006, 2:19:07 PM, you wrote:
G> someone mentioned to me that this expression: G> mapM_ action [n..m] G> isn't being optimised properly, so I thought I'd look into it. Sure
may be, what's me :) i use specially written function as faster version of this idiom and suggested Simon Marlow to substitute "mapM [n..m]" with call to my function using RULE mechanism
SM> The point is that it should already be optimised - both mapM_ and [n..m] SM> work with foldr/build optimisation, but due to the problem reported in SM> that ticket, foldr/build isn't working fully on this example. Better to SM> fix the cause of the problem than work around it with a special RULE. i understood this and therefore don't wrote my function body. but now i write it: -- Faster equivalent of "mapM_ action [from..to]" loop from to action = go from where go i | i>to = return () | otherwise = do action i go $! (i+1) for the following purpose - can you check that 'loop' in no more "faster equivalent", i.e. that the speed is really the same now? -- Best regards, Bulat mailto:bulatz@HotPOP.com