[Haskell-cafe] How to use notFollowedBy function in Parsec
Daniel Fischer
daniel.is.fischer at web.de
Tue Nov 22 10:19:33 EST 2005
Am Dienstag, 22. November 2005 15:58 schrieben Sie:
> Hello,
> I run as follows:
>
> simple::Parser String
> simple = do manyTill anyToken (semi <|> eof)
>
> 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
>
>
> ParsecLanguage> :load Test.hs
> Type checking
> ERROR "Test.hs":21 - Type error in application
> *** Expression : semi <|> eof
> *** Term : semi
> *** Type : GenParser Char () String
> *** Does not match : GenParser a b ()
>
> Do you know what happens? Thank you.
>
Aye, <|> takes two parsers of the same type, so we'd need
manyTill anyToken ((semi >> return () ) <|> eof)
or
manyTill anyToken (semi <|> (eof >> return "dummy String"))
Cheers,
Daniel
More information about the Haskell-Cafe
mailing list