[Haskell-cafe] Re: Abstraction leak

Andrew Coppin andrewcoppin at btinternet.com
Sun Jul 1 08:33:31 EDT 2007

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]

  parseRLE :: Parser Word8 [Word8]

Now, if I want to just do without the RLE bit, I can do

  parseHuffman :: [x] -> Parser Word8 x
  parseHuffman xs = do
    table <- parseHuffmanTable xs
    parseHuffmanPayload table

But if I want to add an RLE layer to just the Huffman table... erm... 
OK, I'm stuck now. :-S

1. How do I run the input through parseRLE and *then* through 

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 

More information about the Haskell-Cafe mailing list