[Haskell-beginners] Unformatted binary IO

Chaddaï Fouché chaddai.fouche at gmail.com
Mon Sep 29 17:35:03 UTC 2014


This is easy in Haskell too and binary provide everything you need. It's
not like you're _forced_ to use the Vector instance to construct a Vector
from your values, you can simply repeat (with replicateM) the get for the
Float (or Double) instance instead and build a Vector from the resulting
list (if you do it properly it will probably fuse into a tight loop anyway).

I don't understand your problem ?

On Mon, Sep 29, 2014 at 5:52 PM, David Raymond <raymond at kestrel.nmt.edu>
wrote:

>
> I am trying to read and write to/from files or stdout/stdin that have
> an ascii header followed by unformatted float32 binary data.  (The
> files are created using a C program.)  The ascii header first needs to
> be parsed to understand the structure of the floating point data.  I
> have solved the parsing problem, but getting the unformatted binary
> float data into a series of float (or double) immutable, unboxed
> vectors has defeated me so far.  The binary package doesn't help as
> far as I can see, as the binary format it reads and writes has some
> control information at the beginning that doesn't exist in the format
> I am reading.
>
> This is easy in C, but seems to be hard in Haskell unless I am missing
> something.
>
> Any suggestions?
>
> --
> David J. Raymond
> Prof. of Physics
> New Mexico Tech
> http://www.physics.nmt.edu/~raymond/index.html
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140929/b2b15fd1/attachment.html>


More information about the Beginners mailing list