On 14 February 2005 19:13, Iavor Diatchki wrote:

> There is something strange that is going on with unboxed types in GHC
> (6.2). I think it is a bug, but perhaps I am missing something.  If
> so, I am quite curious as to what is going on.  Here is the example:
> 
>> import GHC.Exts
> 
> First we define a function that will give us the bottom element of
> the unboxed integers.
> 
>> bot    :: () -> Int#
>> bot ()  = bot ()
> 
> Now we can define a function that will "check" if we have bottom or
> not, 
> by terminating or not.
> 
>> stops  :: Int# -> Bool
>> stops _ = True
>> 
>> test1  :: Bool
>> test1   = stops (bot ())
> 
> As expected (by me), 'test1' does not terminate --- to unbox values
> we have to be strict in them.  So far everything makes sense.  
> However if we simply make 'stops' into a local function, it starts
> terminating: 
> 
>> test2  :: Bool
>> test2   = stops (bot ())
>>   where
>>   stops  :: Int# -> Bool
>>   stops _ = True

It looks like GHC is performing a bogus transformation in the
Simplifier.  It's not correct in general to beta-reduce ((\x.True) e)
into True if e has an unlifted type.

Simon PJ is the caretaker of the simplifier, and he's away on holiday
right now, I'll ask him to take a look when he gets back.

Cheers,
        Simon
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to