Parsec.Combinator:manyTill

まんま

module Main where

import Text.ParserCombinators.Parsec

simpleComment   = do{ string "<!--"
                    ; manyTill anyChar (try (string "-->"))
                    }

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

で、

*Main> run simpleComment "<!-- foo -->"
" foo "
*Main> run simpleComment "<!-- foo"
parse error at (line 1, column 9):
unexpected end of input
expecting "-->"