-allow-extension-for-bottom

Simon Peyton-Jones simonpj at microsoft.com
Mon Oct 11 07:44:49 EDT 2004


Can you give a small program that runs 1000x faster in one form compared
with the other?

Currently, if foo is strict, GHC transforms (2) into (1), not the other
way round. In general, transforming (1) into (2) looks hard, because it
means finding the common portions of two expressions.   But I'd be
interested to see cases where you get a lot of performance from such a
transformations.

Simon

| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org
[mailto:glasgow-haskell-users-
| bounces at haskell.org] On Behalf Of Serge D. Mechveliani
| Sent: 11 October 2004 12:22
| To: haskell at haskell.org
| Cc: glasgow-haskell-users at haskell.org
| Subject: -allow-extension-for-bottom
| 
| Dear Haskell implementors,
| 
| Consider the compilation flag  -allow-extension-for-bottom
| 
| which changes the language meaning so that allows to ignore
| the bottom value. For example, the programs
| 
|    (1)   (\ x -> (if p x then  foo (g x)  else  foo (h x)) )
| and
|    (2)   (\ x -> foo ((if p x then  g x  else  h x)) )
| 
| become equivalent, and many program transformations become
| possible.
| I suspect that after compiling and running of a program under
| -allow-extension-for-bottom  the user will discover many helpful
| information about the original program.
| For example, under  -allow-extension-for-bottom  it may run 1000
| times faster, and then, the user finds out what to change to have
| a 1000 times speed-up for the original program for the standard
| Haskell.
| 
| Thus, in my particular practical example, it is evident to me that
| it is better to specify (2). But many similar effects are hard to
| find out without compiling under  -allow-extension-for-bottom.
| 
| Maybe, the compiler could issue the warnings like, say,
| 
|   "Consider factoring `if' in ...   This may improve ... "
| ?
| 
| Copy, please, the answer to  mechvel at botik.ru,
| 
| -----------------
| Serge Mechveliani
| mechvel at botik.ru
| 
| 
| 
| 
| _______________________________________________
| 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