[Haskell-cafe] Is this Parsec code idiomatic?

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Sep 4 15:40:36 EDT 2009

Hi Serge,

Serge LE HUITOUZE wrote:
> I'm asking some advice on a small piece of code representing a
> simplified version of a treatment I need to perform.
> I have a line-oriented string/file, from which I want to extract
> only a substring of those lines starting with char '+' (the detail
> of the extraction is irrelevant here, I'll just return what follows
> the '+').

This isn't really answering your question, but I thought I'd share 
anyway: why use Parsec to retrieve those lines? It seems a simple 
function is a lot easier:

selectPlus :: String -> [String]
selectPlus = map tail . filter ((== '+') . head) . lines

I hope this helps you.


More information about the Haskell-Cafe mailing list