Parsec.Token:commaSep1

module Main where

import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Token
import Text.ParserCombinators.Parsec.Language

lexer  :: TokenParser ()
lexer  =  makeTokenParser(javaStyle)

run :: Show a => Parser a -> String -> IO ()
run p input
        = case (parse p "" input) of
            Left err -> do{ putStr "parse error at "
                          ; print err
                          }
            Right x  -> print x

で、

Prelude> :l 20081127_parsec00.hs
Compiling Main             ( 20081127_parsec00.hs, interpreted )
Ok, modules loaded: Main.
*Main> :t commaSep1
commaSep1 :: forall a st.
             TokenParser st -> CharParser st a -> CharParser st [a]
*Main> run (commaSep1 lexer (many digit)) ""
Loading package parsec ... linking ... done.
[""]
*Main> run (commaSep1 lexer (many digit)) "123"
["123"]
*Main> run (commaSep1 lexer (many digit)) "123,456,789"
["123","456","789"]
*Main> run (commaSep1 lexer (many digit)) "123,456,"
["123","456",""]