ghc --make expre.hs -o expre Chasing modules from: expre.hs Compiling Main ( expre.hs, expre.o ) expre.hs:29: Couldn't match `IO' against `Either ParseError' Expected type: IO a Inferred type: Either ParseError a1 In the application `parse expr "test" "1+2*3"' In the second argument of `(=<<)', namely `parse expr "test" "1+2*3"' the source was import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Expr expr :: Parser Integer expr = buildExpressionParser table factor "expression" table = [[op "*" (*) AssocLeft, op "/" div AssocLeft] ,[op "+" (+) AssocLeft, op "-" (-) AssocLeft] ] where op s f assoc = Infix (do{ string s; return f}) assoc factor = do{ char '(' ; x <- expr ; char ')' ; return x } <|> number "simple expression" number :: Parser Integer number = do{ ds <- many1 digit ; return (read ds) } "number" main = print =<< parse expr "test" "1+2*3" -- '*' has higher priority