<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Because applying f to the list is not the same thing is applying bind to the list and f.</div><div><br></div><div>Bob</div><br><div><div>On 26 Feb 2011, at 20:17, michael rice wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font: inherit;">Why? Shouldn't this work for any type a?<br><br>Michael<br><br>==========<br><br><span style="font-family: courier,monaco,monospace,sans-serif;">f :: [a] -> [a]</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">f l = do x <- l</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;"> return x</span><br style="font-family: courier,monaco,monospace,sans-serif;"><br>==========<br><br>*Main> :r<br>[1 of 1] Compiling Main ( test.hs, interpreted )<br>Ok, modules loaded: Main.<br>*Main> f "abcde"<br>"abcde"<br>*Main> f [1,2,3,4,5]<br>[1,2,3,4,5]<br>*Main> "abcde" >>=
f<br><br><interactive>:1:12:<br> Couldn't match expected type `Char' against inferred type `m b'<br> In the second argument of `(>>=)', namely `f'<br> In the expression: "abcde" >>= f<br> In the definition of `it': it = "abcde" >>= f<br>*Main> <br><br></td></tr></tbody></table><br>
_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>http://www.haskell.org/mailman/listinfo/haskell-cafe<br></blockquote></div><br></body></html>