Lambda dropping in loops

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Sat, 30 Dec 2000 12:06:25 +1100


Given a function like

  fill 0# mpa = return ()
  fill i# mpa = do
		  let i'# = i# -# 1#
		  writeMP mpa (I# i'#) e
		  fill i'# mpa

it would be nice if GHC were to lambda drop it (on the core
level) into

  fill i# mpa = fill' i#
    where
      fill' 0# = return ()
      fill' i# = do
		   let i'# = i# -# 1#
		   writeMP mpa (I# i'#) e
		   fill' i'#

as this allows it to subsequently apply the new case
liberation optimisation.  By performing the lambda dropping
manually, I have gotten much better code in some performance
sensitive definitions.

Cheers,
Manuel