[Haskell-cafe] Binary IO of a list of ints

2008-01-24 Thread Jamie Love
Hi there I have a list of ints, with values between 0 and 255 and I need to print them out in little endian form to a file. I've been using Data.Binary for single values, e.g. runPut $ do put 'B' put (0 :: Int32) I'm wondering how I can go about writing a list of Ints out. My thought

Re: [Haskell-cafe] Binary IO of a list of ints

2008-01-24 Thread Fraser Wilson
(untested) mapM_ runPut data ? On Jan 24, 2008 12:14 PM, Jamie Love [EMAIL PROTECTED] wrote: Hi there I have a list of ints, with values between 0 and 255 and I need to print them out in little endian form to a file. I've been using Data.Binary for single values, e.g. runPut $ do

Re: [Haskell-cafe] Binary IO of a list of ints

2008-01-24 Thread Jamie Love
Thanks Jed, That works (or at least it's taking ages to error :-) ) Jed Brown wrote: On 24 Jan 2008, [EMAIL PROTECTED] wrote: Hi there I have a list of ints, with values between 0 and 255 and I need to print them out in little endian form to a file. I've been using Data.Binary for

[Haskell-cafe] Binary IO

2006-06-24 Thread jeff lasslett
Greetings,I am considering writing -in Haskell of course - a small program to translate binary files to human readable text.The trouble is that I can find no easily digestible tutorial style info on how to do binary IO in Haskell. I have read about some of the libraries that people have created to

Re: [Haskell-cafe] Binary IO

2006-06-24 Thread Donald Bruce Stewart
m4d.skills: Greetings, I am considering writing -in Haskell of course - a small program to translate binary files to human readable text. The trouble is that I can find no easily digestible tutorial style info on how to do binary IO in Haskell. I have read about some of

Re: [Haskell-cafe] Binary IO

2006-06-24 Thread Bulat Ziganshin
Hello jeff, Saturday, June 24, 2006, 10:19:17 AM, you wrote: I would greatly appreciate it if someone could post a small example or two illustrating how to do binary IO in Haskell using the most widely used binary IO lib (if there is such a thing).  Failing that, I would appreciate a link

RE: Erlang vs. Haskell (was Re: [Haskell-cafe] binary IO)

2005-12-29 Thread Simon Peyton-Jones
| Using Haskell for this networking app forced me to focus on all the | issues _but_ the business logic. Type constraints, binary IO and | serialization, minimizing memory use and fighting laziness, timers, | tweaking concurrency and setting up message channels, you name it. That's a

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Joel Reymont
On Dec 27, 2005, at 10:30 PM, Tomasz Zielonka wrote: Let's see if I understand correctly. There are 17605 messages in trace.dat. On my hardware the average message unpicking time is 0.0002s when you only have a single thread. So, it indeed seems that with 1000 threads it should be possible

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Einar Karttunen
On 27.12 07:00, Tomasz Zielonka wrote: Some time ago I was playing with DNS too. I have a library that can construct and interpret DNS packets, but it's a bit incomplete right now. It reads packets as Strings, but it should be quite straightforward to make it read and interpret

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Lennart Augustsson
Joel Reymont wrote: You are right in that I spent the first few weeks learning. By now I know that pickling is the bottleneck, though. The timeleak code is very simple. It forks X threads where each thread opens a file for reading. Why on earth do you want each tread to open the file and

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Joel Reymont
On Dec 28, 2005, at 11:40 AM, Lennart Augustsson wrote: Why on earth do you want each tread to open the file and unpickle? Why not unpickle once and reuse it? Or, if this is just a test and in the future they will all read from different files (or sockets), then maybe you are hitting on a

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Sebastian Sylvan
On 12/28/05, Joel Reymont [EMAIL PROTECTED] wrote: On Dec 28, 2005, at 11:40 AM, Lennart Augustsson wrote: Why on earth do you want each tread to open the file and unpickle? Why not unpickle once and reuse it? Or, if this is just a test and in the future they will all read from

Erlang vs. Haskell (was Re: [Haskell-cafe] binary IO)

2005-12-28 Thread Joel Reymont
On Dec 28, 2005, at 1:05 PM, Sebastian Sylvan wrote: How does this work if you remove the file-reading? I mean just putting the file on a small TCP/IP file server with some simulated latency and bandwidth limitation, and then connecting to that in each thread? This is probably the way to go

[Haskell-cafe] binary IO

2005-12-27 Thread Dominic Steinitz
It might also be worth looking at the networking code in House given the intended application is parsing network packets. See http://www.cse.ogi.edu/~hallgren/House/kernel/pfe.cgi?Net.PacketParsing, for example. Dominic. ___ Haskell-Cafe mailing

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Joel Reymont
Tomasz, Try http://wagerlabs.com/timeleak.tgz. See the Killer pickler combinators thread as well. My desired goal is to have 4k bots (threads?) running at the same time. At, say, 1k/s per bot I figure something like 4Mb/s round-trip. Each bot cannot spend more than a couple of seconds on

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Bulat Ziganshin
Hello Pupeno, Tuesday, December 27, 2005, 7:10:24 AM, you wrote: P It seems I have found a hole in Haskell... :( lazy language can't contain holes, they are just yet unevaluated thunks :) P I basically need a set of functions to read binary data out of a Handle (a P higher lever of hGetBuf and

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Branimir Maksimovic
From: Joel Reymont [EMAIL PROTECTED] To: Tomasz Zielonka [EMAIL PROTECTED] CC: Jeremy Shaw [EMAIL PROTECTED],haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] binary IO Date: Tue, 27 Dec 2005 09:18:54 + Tomasz, Try http://wagerlabs.com/timeleak.tgz. See the Killer pickler

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Joel Reymont
We'll see, Erlang is built for this type of stuff. I might have results from the timeleak test today and will probably have first networking results tomorrow. But I wish I could achieve even a fraction of that with Haskell. On Dec 27, 2005, at 9:51 AM, Branimir Maksimovic wrote: I have

Re[2]: [Haskell-cafe] binary IO

2005-12-27 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 27, 2005, 12:18:54 PM, you wrote: JR My desired goal is to have 4k bots (threads?) running at the same JR time. At, say, 1k/s per bot I figure something like 4Mb/s round-trip. no problem. my library handle about 10-15mb/s, and i think that speed can be doubled by

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Pupeno
On Tuesday 27 December 2005 02:10, Jeremy Shaw wrote: they do not care about big endian vs little endian. Does it mean that it just reads the data in whatever endianess the computer is in, right ? However, while the Binary class in NewBinary may not be appropriate, the uniform interface to

Re: Re[2]: [Haskell-cafe] binary IO

2005-12-27 Thread Joel Reymont
Bulat, On Dec 27, 2005, at 1:58 PM, Bulat Ziganshin wrote: no problem. my library handle about 10-15mb/s, and i think that speed can be doubled by using unboxed ints Would you like to present your version of the timeleak code plus statistics from a test run? This will demonstrate the

Re[2]: [Haskell-cafe] binary IO

2005-12-27 Thread Bulat Ziganshin
Hello Pupeno, Tuesday, December 27, 2005, 6:12:37 PM, you wrote: they do not care about big endian vs little endian. P Does it mean that it just reads the data in whatever endianess the computer is P in, right ? NewBinary read/write data in so-called network format, which is the same as in

Re[4]: [Haskell-cafe] binary IO

2005-12-27 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 27, 2005, 6:24:56 PM, you wrote: no problem. my library handle about 10-15mb/s, and i think that speed can be doubled by using unboxed ints JR Would you like to present your version of the timeleak code plus JR statistics from a test run? do it yourself. i

Re: Re[4]: [Haskell-cafe] binary IO

2005-12-27 Thread Joel Reymont
On Dec 27, 2005, at 4:52 PM, Bulat Ziganshin wrote: spending several weeks to random optimization is like buying a gold computer case trying to speed up the game :) I did not spend several weeks on optimization. I went through about 25 iterations with the timeleak code and the profiler. I

Re: Re[4]: [Haskell-cafe] binary IO

2005-12-27 Thread Gour
On Tue, 2005-12-27 at 18:35 +, Joel Reymont wrote: Hi Joel! Then we can lay out the series of profiling reports in a storyboard of sorts, with changes from report to report described. This would serve a great how to write efficient Haskell manual. We are with you watching your

Re: Re[4]: [Haskell-cafe] binary IO

2005-12-27 Thread Joel Reymont
That's great to hear! I will continue once I have a chance to discuss it with the gurus and optimize it further. At the same time, I would challenge everyone with a fast IO library to plug it into the timeleak code, run it under a profiler and post the results (report + any alarms). The

Re: [Haskell-cafe] binary IO

2005-12-27 Thread Tomasz Zielonka
On Tue, Dec 27, 2005 at 09:18:54AM +, Joel Reymont wrote: Try http://wagerlabs.com/timeleak.tgz. See the Killer pickler combinators thread as well. Let's see if I understand correctly. There are 17605 messages in trace.dat. On my hardware the average message unpicking time is 0.0002s when

Re: [Haskell-cafe] binary IO

2005-12-26 Thread Donald Bruce Stewart
mcqueenorama: How is this different from the (un)pickle process that has been discussed here recently? Recently I've seen the Binary discussions, and the pickeling discussions, and I noticed they seemed to be talking about the same process. Yep, same thing. -- Don

Re: [Haskell-cafe] binary IO

2005-12-26 Thread Tomasz Zielonka
On Tue, Dec 27, 2005 at 07:00:12AM +0100, Tomasz Zielonka wrote: I've just glanced at the code, and yes, it is a bit of a mess. I'll see if I can tidy it up. Perhaps you could help me? I've just made the parser more generic, which helped to reduce code duplication. Maybe I will finally manage

Re: [Haskell-cafe] binary IO

2005-12-26 Thread Jeremy Shaw
On Dec 26, 2005 10:20 PM, Brian McQueen [EMAIL PROTECTED] wrote: How is this different from the (un)pickle process that has been discussed here recently? There is one important difference in my mind. Most of the pickling code is concerned with turning haskell data into a binary stream that