
Using the IsString instance for Parser in attoparsec is really nice, but unfortunately, you can't use it out of the box for the most common case. One would like to be able to write parsers in this style: "(" *> stuff <* ")" But the types of *> and <* are too general - there is no way for the type checker to figure out which instance of IsString to use for the discarded parameter. I suggest adding the following type-specialized variants to Data.Attoparsec.Char8: (<*.) :: Applicative f => f a -> f ByteString -> f a (<*.) = (<*) (.*>) :: Applicative f => f ByteString -> f a -> f a (.*>) = (*>) Once attoparsec-text gets its IsString instance, I would add the same thing to Data.Attoparsec.Text, with ByteString replaced by Text. I have been using those for both attoparsec and attoparsec-text, and I find them extremely useful. Thanks, Yitz

On Tue, Jan 25, 2011 at 5:16 AM, Yitzchak Gale
I suggest adding the following type-specialized variants to Data.Attoparsec.Char8:
(<*.) :: Applicative f => f a -> f ByteString -> f a (<*.) = (<*)
(.*>) :: Applicative f => f ByteString -> f a -> f a (.*>) = (*>)
Sounds reasonable. Send a patch?

On Wed, Jan 26, 2011 at 7:43 PM, Bryan O'Sullivan
On Tue, Jan 25, 2011 at 5:16 AM, Yitzchak Gale
wrote: I suggest adding the following type-specialized variants to Data.Attoparsec.Char8:
(<*.) :: Applicative f => f a -> f ByteString -> f a (<*.) = (<*)
(.*>) :: Applicative f => f ByteString -> f a -> f a (.*>) = (*>)
Sounds reasonable. Send a patch?
Done! It will be in attoparsec-text 0.8.2.0. Bryan, I don't know how to give you a patch using Mercurial, so I've used 'hg export -r 231 -o ../attoparsec_applicative.hg_export'. The patch is basically the same as attoparsec-text's. Cheers! =) -- Felipe.

I wrote:
I suggest adding the following type-specialized variants to Data.Attoparsec.Char8:
(<*.) :: Applicative f => f a -> f ByteString -> f a (<*.) = (<*)
(.*>) :: Applicative f => f ByteString -> f a -> f a (.*>) = (*>)
Bryan O'Sullivan wrote:
Sounds reasonable. Send a patch?
Felipe Almeida Lessa wrote:
Done! It will be in attoparsec-text 0.8.2.0.
Fantastic.! Felipe, thanks so much for this patch, and for the IsString instance in attoparsec-text. Regards, Yitz
participants (3)
-
Bryan O'Sullivan
-
Felipe Almeida Lessa
-
Yitzchak Gale