Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-28 Thread Tomasz Zielonka
On Mon, Jan 26, 2004 at 02:39:32PM -0800, John Meacham wrote: On Mon, Jan 26, 2004 at 01:24:37PM +0100, Tomasz Zielonka wrote: 3) Roll your own (de)serialization framework That's what I did. It's a bit complicated, but I will try to describe it within a couple of days. Right now all I

[Haskell-cafe] Interpreting fields in a buffer

2004-01-27 Thread Dominic Steinitz
I looked at the Erlang syntax when I wrote my helper functions and I agree it is very nifty. I didn't have the time to investigate how to do it in Haskell but it would be disappointing if it (or something like it) couldn't be done. Dominic. Mikael, Thanks, that's very helpful and seems to be

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-27 Thread Jeremy Shaw
Hello, I just wanted to chime in with a 'me too' in regards to this whole thread. Many of the programs I want to write involve reading and writing binary file formats, and writing the code to actually do that tends to be the ugliest, most error prone, boring part of the whole program. I have not

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-26 Thread Alastair Reid
I have a question related to a program I'm writing. I have to handle IP packets, which will be read into a buffer. What is the best haskell idiom for getting access to the fields in the buffer? There's no way in Haskell to define a datastructure with a particular memory layout. (Strictly,

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-26 Thread Tomasz Zielonka
On Mon, Jan 26, 2004 at 10:34:06AM +, Alastair Reid wrote: To access the fields, you will need to write a bunch of functions to read them out (and write them if you need). There's basically two approaches: 1) Write access functions in C and use the ffi interface to call them. For

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-26 Thread Glynn Clements
Alastair Reid wrote: 2) Write access functions in Haskell using functions from the Storable class and associated libraries. In this case, using Storable probably isn't worth the trouble, given that 1. The 16- and 32-bit fields are in network byte order, whereas Storable assumes host byte

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-26 Thread Mikael Brockman
On mån, 2004-01-26 at 12:22 -0500, Gregory Wright wrote: Hi Dominic, First, thanks to everyone for their help. RIght now, I'm leaning toward Dominic's solution of a collection of helper functions, but I have the feeling that we should be generating them automatically. After all, given a

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-26 Thread Gregory Wright
Mikael, Thanks, that's very helpful and seems to be just the sort of thing I'm looking for. Greg On Jan 26, 2004, at 6:05 PM, Mikael Brockman wrote: You'll probably want to take a look at Erlang's so called ``bit syntax'' at http://www.erlang.se/euc/00/bit_syntax.html. It's very nifty, and I'd

[Haskell-cafe] Interpreting fields in a buffer

2004-01-25 Thread Gregory Wright
Hi, I have a question related to a program I'm writing. I have to handle IP packets, which will be read into a buffer. What is the best haskell idiom for getting access to the fields in the buffer? The IP header has a number of fixed format fields. In C, I would define a struct, then cast the