[Haskell-cafe] Parsing binary data.

Adam Langley agl at imperialviolet.org
Mon Aug 20 14:57:11 EDT 2007


On 8/19/07, Matthew Sackman <matthew at wellquite.org> wrote:
> But it's vastly harder to do that for floats / non-integers. Now I know
> that the number classes in the Prelude are basically broken anyway and
> all really need rewriting, but it does seem completely arbitrary that
> Words somehow are only allowed to contain whole numbers!

Well, see the attached patch to Data.Binary to add
putFloat[32|64][be|le]. I got bored, so adding the Get functions is an
exercise for the reader :)

(And so because I think it needs unsafeSomethingIO and I'm a little
unsure about that).

If these functions would be useful for you, you should bug the binary
team to add something similar.


AGL

-- 
Adam Langley                                      agl at imperialviolet.org
http://www.imperialviolet.org                       650-283-9641
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data-binary-float.darcs
Type: application/octet-stream
Size: 5797 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070820/12a8ad07/data-binary-float-0001.obj


More information about the Haskell-Cafe mailing list