Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Philip Armstrong
On Sun, Jul 01, 2007 at 06:07:13PM +0100, Andrew Coppin wrote: I haven't actually tried, but presumably a TCP connection is represented in the same way as a file, and so has the same problems. Basically doing binary I/O seems to be one of those things that in Haskell falls into the class of

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Donald Bruce Stewart
phil: On Sun, Jul 01, 2007 at 06:07:13PM +0100, Andrew Coppin wrote: I haven't actually tried, but presumably a TCP connection is represented in the same way as a file, and so has the same problems. Basically doing binary I/O seems to be one of those things that in Haskell falls into the

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Thomas Conway
Anyone trying to do any of this? I've done some work in this area. I'm particularly interested in manipulating ASN.1 in haskell. Actually, my first use of Parsec was an ASN.1 parser. I'd done one previously in Spirit (the Boost C++ rip-off of parsec), but semantic actions were horrible in the

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Donald Bruce Stewart
drtomc: Anyone trying to do any of this? I've done some work in this area. I'm particularly interested in manipulating ASN.1 in haskell. Actually, my first use of Parsec was an ASN.1 parser. I'd done one previously in Spirit (the Boost C++ rip-off of parsec), but semantic actions were

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Philip Armstrong
On Wed, Jul 04, 2007 at 09:02:15PM +1000, Donald Bruce Stewart wrote: phil: On Sun, Jul 01, 2007 at 06:07:13PM +0100, Andrew Coppin wrote: I haven't actually tried, but presumably a TCP connection is represented in the same way as a file, and so has the same problems. Basically doing binary

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Donald Bruce Stewart
phil: On Wed, Jul 04, 2007 at 09:02:15PM +1000, Donald Bruce Stewart wrote: phil: On Sun, Jul 01, 2007 at 06:07:13PM +0100, Andrew Coppin wrote: I haven't actually tried, but presumably a TCP connection is represented in the same way as a file, and so has the same problems. Basically

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Donald Bruce Stewart
drtomc: On 7/4/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote: Can we do a cheap bytestring binding to libxml, to avoid any initial String processing? For my part, it's not too big an issue. A version of HaXml or at least Parsec built on top of ByteString would be a good start. I know

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-04 Thread Thomas Conway
On 7/5/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote: Yep. The current impl is: mmapFile :: FilePath - IO ByteString mmapFile f = mmap f = \(fp,l) - return $! PS fp 0 l mmap :: FilePath - IO (ForeignPtr Word8, Int) mmap = do ... p - mmap l fd fp -

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Am I missing something or why wouldn't encode, decode :: String - String encode = encodeRLE . encodeHuffman decode = decodeHuffman . decodeRLE do the job? This is probably what Andrew intends to do in his Java version. Note that this not only RLE-encodes the Huffman table

[Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread apfelmus
Andrew Coppin wrote: apfelmus wrote: Am I missing something or why wouldn't encode, decode :: String - String encode = encodeRLE . encodeHuffman decode = decodeHuffman . decodeRLE do the job? This is probably what Andrew intends to do in his Java version. Note that this not only

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Andrew Coppin wrote: It is enough. But given that the whole purpose of compression algorithms is to squeeze data into the tiniest possible space, I wanted to avoid having a size field. And mathematically it's perfectly possible to do... I just can't find a convinient way to

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
OK, well I don't know the Parsec types and function names off the top of my head, but suppose I have the following: runParser :: Parser a b - [a] - Either ParseError b parseHuffmanTable :: [x] - Parser Word8 (HuffmanTable x) parseHuffmanPayload :: HuffmanTable x - Parser Word8 [x]

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Andrew Coppin wrote: OK, I'm stuck now. :-S 1. How do I run the input through parseRLE and *then* through parseHuffmanTable? 2. How do I get parseHuffmanPayload to continue from where parseRLE left off? (How do I get parseRLE to not parse the entire input, for that

[Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Jon Fairbairn
Andrew Coppin [EMAIL PROTECTED] writes: While we're on the subject... am I the first person to notice that Haskell doesn't appear to have much support for fiddling with streams of bits? No. Presumably the author of Data.Bits noticed some lack. (Note that Integer is an instance of Num and

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
Jon Fairbairn wrote: Andrew Coppin [EMAIL PROTECTED] writes: While we're on the subject... am I the first person to notice that Haskell doesn't appear to have much support for fiddling with streams of bits? No. Presumably the author of Data.Bits noticed some lack. (Note that Integer

[Haskell-cafe] Re: Abstraction leak

2007-06-30 Thread apfelmus
David Roundy wrote: On Fri, Jun 29, 2007 at 07:39:28PM +0100, Andrew Coppin wrote: Now I have a problem. It's easy enough to pass the entire data stream through an RLE decoder and feed that to the Huffman table deserialize function, and it will give be back the table. But I now have *no