Thanks much Kim, that was very helpful.
Your questions aren't lame. They are common confusions from those who come from a not-so-mathy background.
Your first question:
Shouldn't the return type be of (Char, [Char])?
suggests that you're confusing the type synonym of (Parser a), which is String -> (a, String), with just the right-hand-side, (a, String).
Your "z" expression has type Parser ([Char], Char), which means the same thing as String -> ((String, Char), String).
How did that happen?
Because
item `bind` (\x -> (\y -> result (x,y))) "Rohit"_______________________________________________is equivalent to
item `bind` ( (\x -> (\y -> result (x,y))) "Rohit" )
as those last two expressions go together by the parsing rules.
So what you actually have is
item `bind` (\y -> result ("Rohit",y))
The first argument to bind has type Parser Char, the second argument (a -> Parser (String,a)).
The result is exactly what's expected: Parser (String, Char), i.e. String -> ((String, Char), String).
p.s. This might be what you're looking for: Try evaluating
item "Rohit"
in the repl.-- Kim-Ee
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners