The docs for unsafeCoerce# say:
The following uses of unsafeCoerce# are supposed to work (i.e. not lead to
spurious compile-time or run-time crashes):
# Casting any lifted type to Any
# Casting Any back to the real type
# Casting an unboxed type to another unboxed type of the same size (but not
On Thu, Jul 08, 2010 at 04:49:00PM +0200, Daniel Fischer wrote:
unsafeCoerce# :: Word64# - Double# ?
By the docs, that isn't supposed to work. Is it not supposed to work only
because it's not value-preserving (unsafeCoerce# 1## /=## 1.0##) or are
there more pitfalls?
It can fail to
On Thursday 08 July 2010 18:15:44, Ian Lynagh wrote:
On Thu, Jul 08, 2010 at 04:49:00PM +0200, Daniel Fischer wrote:
unsafeCoerce# :: Word64# - Double# ?
By the docs, that isn't supposed to work. Is it not supposed to work
only because it's not value-preserving (unsafeCoerce# 1## /=##
On Thu, Jul 08, 2010 at 04:49:00PM +0200, Daniel Fischer wrote:
If there are more pitfalls, is there any chance of getting a function which
reinterprets the bit-patterns?
Hi, you can do something like this (untested):
castWordToFloat :: Word32 - Float
castWordToFloat w = unsafePerformIO $ do
Hello everyone,
I'm currently in the process of wrapping a C API, and I've run across
an interesting possibility. Basically, the C API exposes non-blocking
versions of some potentially long-running operations, and will invoke
a callback to indicate that the long running operation has finished.
On Thu, Jul 8, 2010 at 3:25 PM, J. Garrett Morris jgmor...@cs.pdx.edu wrote:
Hello everyone,
I'm currently in the process of wrapping a C API, and I've run across
an interesting possibility. Basically, the C API exposes non-blocking
versions of some potentially long-running operations, and
Consider
newtype Foo = Foo Int
lift :: (Int - a) - Foo - a
lift f (Foo x) = f x
Now, I'd expect this to compile with -O2 down to something like
lift f = f `cast` (Foo - a)
but it doesn't.
It seems that GeneralizedNewtypeDeriving assumes that these two things *are*
equivalent, and it just