Consider the following piece of Haskell code:
type Parser a = String -> [(a, String)]
item :: Parser Char
item = \ inp -> case inp of
[] -> []
(x:xs) -> [(x, xs)]
ret :: a -> Parser a
ret v = \ inp -> [(v, inp)]
parse :: Parser a -> String -> [(a, String)]
parse p inp = p inp
pseq :: Parser (Char, Char)
pseq = do x <- item
item
y <- item
ret (x, y)
ac = parse pseq "abcdef"
When trying to run the above code in hugs (Version September 2006), I get the following error message:
Type error in explicitly typed binding
*** Term : pseq
*** Type : [Char] -> [(([(Char,[Char])],[(Char,[Char])]),[Char])]
*** Does not match : Parser (Char,Char)
And, when I remove my type declaration for "pseq", I get the following error message:
Unresolved top-level overloading
*** Binding : pseq
*** Outstanding context : Monad ((->) [Char])