Oops, two more mistakes:

It's `toParser_`, not `toParser'`.

Also, `maxLines` still has a mistake because it doesn't re-yield the newline byte. Maybe I should provide a `line` lens that includes the newline byte for simplicity. Anyway, it's a digression from the discussion.

On 01/31/2014 03:49 PM, Gabriel Gonzalez wrote:
Alright, so I added two utilities to `pipes-parse` for converting `Consumer`s to `Parser`s:

    toParser :: Monad m => Consumer (Maybe a) m r -> Parser a m r

    toParser' :: Monad m => Consumer a m X -> Parser a m ()

These cover most common cases with good efficiency.

Also, I noticed there was a slight mistake in my example implementation of `maxLines` because it was not consuming the newline byte. The correct version is this:

    maxLines n = iso (cut n) join
      where
        cut 0 p = return p
        cut n p = do
            p'  <- p ^. PB.line
            p'' <- lift (execStateT PB.drawByte p')  -- Drain newline byte
            cut (n - 1) p''
--
You received this message because you are subscribed to the Google Groups "Haskell Pipes" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].

--
You received this message because you are subscribed to the Google Groups "Haskell 
Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to