[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] sizeOf on a type

Subject: Re: [Haskell-cafe] sizeOf on a type
From: wren ng thornton
Date: Sat, 19 Dec 2009 19:21:57 -0500
Sean Leather wrote:
I can see what's going on:  it can't tell that the "a" I am writing there
is the same "a" that's in the type specification, but is there any way that
I can make it identify "a" with the "a" in the specification for nextPtr?

Lexically scoped type variables:
And if you require H98+FFI only, you can also use the following:

    ptrSizeOf = sizeOf . asTypeOf undefined . unsafePerformIO . peek

The asTypeOf function is the H98 way of handling many scoped type variable issues. It never evaluates its second argument so the unsafePerformIO is perfectly safe since the peek will never be evaluated either (and, heck, the whole argument to sizeOf won't be evaluated either).
Live well,
Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>