[Haskell-cafe] Abstraction leak

Andrew Coppin andrewcoppin at btinternet.com
Fri Jun 29 18:14:39 EDT 2007


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 clue* 
>> where the table ends in the original stream!
>>     
>
> Sounds to me like you want a parsing monad.  Generally, when you want
> state, you want a monad, and the field of parsing monads is pretty mature.
> You can either write up a monad of your own, or use one of the existing
> ones (parsec, frisby, read).
>   

Perhaps. But how do you run a parser on top of another parser? More 
importantly, how do you stack several parsers one on top of the other, 
get the top-most one to return the thing it parsed, and then make a 
completely different stack of parsers process the remainder?

I'm sure it can be done, but... I'm having trouble wrapping my mind 
around that at this time of night... :-S



More information about the Haskell-Cafe mailing list