Top-level bindings for unlifted types

Isaac Dupree isaacdupree at
Tue Nov 13 20:44:09 EST 2007

Neil Mitchell wrote:
> Hi
>> Top-level unboxed values would then
>> behave just like #define constants, in fact.  This is certainly possible,
>> it would just add complexity to the compiler in various places.
> Yes, that was all I was thinking of. I'm not suggesting that these
> things actually get implemented, but it did seem a strange restriction
> that it would have been impossible to define something like realWorld#
> in Haskell without baking it into the compiler.
>> What would you expect to happen for this?
>> fib :: Int -> Int#
>> fib n = ...
>> x :: Int#
>> x = fib 100#
>> 'x' cannot be bound to a thunk.  So the top-level computation would have to be evaluated eagerly.  But when?  Perhaps when the program starts?
> Yes, when the program starts seems perfectly sensible - and mirrors
> what happens in C, I believe.

IIRC, C only allows compile-time constants (such as 1+1), and C++ has 
the behavior you describe (non-constants computed at load time - which 
is criticized for nondeterministic order, slow loading having to go 
through many areas of memory...)

More information about the Glasgow-haskell-users mailing list