<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 14, 2015 at 10:52 AM, Kim-Ee Yeoh <span dir="ltr"><<a href="mailto:ky3@atamo.com" target="_blank">ky3@atamo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra">What we're seeing is special handling for stage 3: reporting errors in a do-block. Sometimes it helps, sometimes it hinders. For instance, the derivation of this signature is confusing indeed:<br></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="adL"><span class=""><span style="font-family:monospace,monospace">   IO System.IO.Handle<br>-> (System.IO.Handle -> IO Data.ByteString.ByteString)<br>-> Data.ByteString.ByteString</span></span></div></div></blockquote></div><br>To elaborate, the error message comes from the compiler choking on the monadic bind (>>=) that reveals itself in the desugared code.<br><br>The (>>=) results from desugaring<br><br>   file <- openBinaryFile filename ReadMode<br><br>into<br><br>   openBinaryFile filename ReadMode >>= \file -> ...<br><br>The compiler knows the type signature of (>>=), which wants to see<br><br>   IO Handle -> (Handle -> IO ByteString) -> IO ByteString<br><br>But the signature of the top-level function insists on<br><br>   IO Handle -> (Handle -> IO ByteString) -> ByteString<br><br>This is what's the compiler's trying to say.<br><br><br clear="all"><div><div class="gmail_signature">-- Kim-Ee</div></div>
</div></div>