Is there a way to optimize out some foreign calls?

Simon Peyton-Jones simonpj at microsoft.com
Mon Apr 10 09:56:18 EDT 2006


| I'm thinking in terms of some way of marking foreign functions to
specify
| how they can be optimized out or specifying rewrite sequences eg
| 
|              x >> api_sync >> api_pop >> api_sync >> y = x >> api_pop
>>
| api_sync >> y

You should be able to say something like

   RULE
	api_sync >>= (\_ -> api_pop >>= rest) = api_pop >>= rest
	api_pop >>= (\_ -> api_sync >>= rest) = api_pop >>= rest

Do-notation is desugared to (>>=) stuff.  

Give it a try on a small example and see if it works

SImon
| 
| I've read the manual (7.10) on rewrite rules, but I'm having
difficulty
| understanding how to express the lhs of the above equation as a
rewrite rule
| so that it matches a sequence anywhere in a do block (to deal with
nested
| parentheses and the use of >>= instead of >>)
| 
| Any ideas?
| 
| Thanks, Brian.
| 
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list