[Haskell-cafe] Parsing words with parsec
stefanor at cox.net
Fri Mar 30 00:59:58 EDT 2007
On Fri, Mar 30, 2007 at 05:43:34AM +0200, paolino wrote:
> I had a bad time trying to parse the words of a text.
> I suspect I miss some parsec knowledge.
I'd start by not sextuple-posting, it just sextuples the ugliness ;-)
Anyway, I think parsec is *far* too big a hammer for the nail you're trying to hit.
import Char( isAlpha )
import List( groupBy )
equating f x y = f x == f y -- in Data.Eq, iff you have GHC 6.7
isLetter x = isAlpha x || x == '_' || x == '@'
myWords = filter (isLetter . head) . groupBy (equating isLetter)
More information about the Haskell-Cafe