<div dir="ltr"><div>Hi All,</div><div><br></div><div>Sorry if this is a very lame question but i am a beginner and much appreciate if some one could correct me?</div><div><br></div><div>I am reading haskell book and curious why the return type of the bind operator look odd to me</div><div><br></div><div>For the given definitions</div><div><br></div><div><i><b>    type Parser a = String -> [(a, String)]</b></i></div><div><i><b>    </b></i></div><div><i><b>    item :: Parser Char</b></i></div><div><i><b>    item = \inp -> case inp of </b></i></div><div><i><b>                       [] -> []</b></i></div><div><i><b>                       (x:xs) -> [(x,xs)]</b></i></div><div><i><b>    </b></i></div><div><i><b>    bind :: Parser a -> (a -> Parser b) -> Parser b</b></i></div><div><i><b>    p `bind` f = \inp -> concat [ f x inp' | (x, inp') <- p inp]</b></i></div><div><br></div><div><br></div><div>when I define z in GHCI as </div><div><br></div><div><i>   <b> let z = item `bind` (\x -> (\y -> result (x,y))) "Rohit"</b></i></div><div><br></div><div>the return type is </div><div><br></div><div><i><b>    >> :t z</b></i></div><div><i><b>    z :: Parser ([Char], Char)</b></i></div><div><br></div><div>Question:</div><div>(1) Shouldn't the return type of (Char, [Char])? looking at the list comprehension, "(x, inp') <- p inp" should yield -> "('r', "ohit")". Next f x inp' is left associative, so f x should yield character 'r' and pass to the lambda that should return result tuple ('r', "ohit"), but why is it that z type is ([Char], char) :: (x,y)</div><div><br></div><div>(2) How can i print the value of z in the above case on the ghci</div><div><br></div><div><br></div><div>Many thanks,</div><div>Rohit</div><div><br></div></div>