Optimisation and unsafePerformIO

Albert Lai trebla@vex.net
30 Oct 2002 01:35:05 -0500


"David Sabel" <dsabel@stud.uni-frankfurt.de> writes:

> {-# NOINLINE b #-}
> 
> b x  = if even x then unsafePerformIO getChar else bot
> 
> bot = bot
> 
> main = do
>          putChar (b 4)
>          putChar (b 6)

I am not a compiler implementer (or lawyer, for that matter :)
But I propose this guess.  First, both even 4 and even 6 get
constant-folded to True; so b 4 and b 6 both become unsafePerformIO
getChar.  Then there is a common subexpression elimination.