Hi,

I'd like to know if this should work:

-- GHC coercion
getFloat :: BHeader -> Get Float
getFloat h =
  case endianness h of
    LittleEndian -> fmap (coerce . fromIntegral) getWord32le
    BigEndian -> fmap (coerce . fromIntegral) getWord32be
  where coerce (I32# x) = F# (unsafeCoerce# x)

-- GHC coercion
getDouble :: BHeader -> Get Double
getDouble h =
  case endianness h of
    LittleEndian -> fmap (coerce . fromIntegral) getWord64le
    BigEndian -> fmap (coerce . fromIntegral) getWord64be
  where coerce (I64# x) = D# (unsafeCoerce# x)

Loading this into ghci compiles fine (but I haven't try to parse
data), but compiling with ghc (6.10.1 or 6.10.4) reports:
/tmp/ghc1967_0/ghc1967_0.s: Assembler messages:

/tmp/ghc1967_0/ghc1967_0.s:287:0:
     Error: bad register name `%fake0'

/tmp/ghc1967_0/ghc1967_0.s:349:0:
     Error: bad register name `%fake0'

Thanks for any help,
Thu
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to