Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Unformatted binary IO (David Raymond)
2. Re: Unformatted binary IO (Chadda? Fouch?)
3. Re: Unformatted binary IO (Brent Yorgey)
4. Re: HXT: encoding problem (Elias Diem)
5. Re: Unformatted binary IO (David Raymond)
----------------------------------------------------------------------
Message: 1
Date: Mon, 29 Sep 2014 09:52:43 -0600
From: David Raymond <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Unformatted binary IO
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
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
------------------------------
Message: 2
Date: Mon, 29 Sep 2014 19:35:03 +0200
From: Chadda? Fouch? <[email protected]>
To: David Raymond <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Unformatted binary IO
Message-ID:
<CANfjZRYyt4DL9xzvBW3s3JE_mveT2=EwSnfGVvv_4=sogid...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
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 <[email protected]>
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
> [email protected]
> 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-0001.html>
------------------------------
Message: 3
Date: Mon, 29 Sep 2014 19:43:00 -0400
From: Brent Yorgey <[email protected]>
To: David Raymond <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Unformatted binary IO
Message-ID:
<CAH0njdtOz=olvk8nxywk0x2gdh68dk8c+sadmczqkocmrvr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I am not sure I have quite understood your problem, but perhaps the
data-binary-ieee754 package may be of use?
-Brent
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
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140929/f9eb54c2/attachment-0001.html>
------------------------------
Message: 4
Date: Tue, 30 Sep 2014 09:23:45 +0200
From: Elias Diem <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] HXT: encoding problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Hi Jeda?
On 2014-09-29, Chadda? Fouch? wrote:
> readString is documented as not doing any decoding, so you're dependent on
> your readFile doing it right for you, but that depends on your locale !
> You could set your IO system input encoding yourself to avoid the problem
> but it seems simpler to use "readDocument" provided by Hxt instead since
> that'll read the file with your specified input encoding.
I use readDocument now as sugested and it works. Thanks for
the explanation.
Thanks to the others too!
--
Greetings
Elias
------------------------------
Message: 5
Date: Tue, 30 Sep 2014 04:56:41 -0600
From: David Raymond <[email protected]>
To: Brent Yorgey <[email protected]>, Chadda? Fouch?
<[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Unformatted binary IO
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Brent Yorgey writes:
> I am not sure I have quite understood your problem, but perhaps the
> data-binary-ieee754 package may be of use?
>
> -Brent
This package looks interesting. However, I am a true Haskell beginner
and I am having a hard time figuring out how the various Binary packages
are actually used to read and write files. Any help or pointers to
tutorials would be greatly appreciated.
Dave
--
David J. Raymond
Prof. of Physics
New Mexico Tech
http://www.physics.nmt.edu/~raymond/index.html
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 75, Issue 24
*****************************************