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)
--
If you don't mind a small performance penalty, have you considered
using my library data-binary-ieee754? It contains functions for
parsing floats and doubles within the Get monad.
On Mon, Sep 14, 2009 at 12:24, minh thu wrote:
> Hi,
>
> I'd like to know if this should work:
>
> -- GHC coercion
>
Hi,
Yes I did but since I saw that 'solution', I wanted to try it.
There is something that bothers me with your library: its licence.
Reading a float shouldn't force me to go GPL (I makes an utility to
read Blender files and like to make it BSD3).
Thanks for pointing it though.
Cheers,
Thu
200
On Mon, Sep 14, 2009 at 12:24 PM, minh thu wrote:
> 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 . fromIntegra
2009/9/14 Judah Jacobson :
> On Mon, Sep 14, 2009 at 12:24 PM, minh thu wrote:
>> 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
>>