On Sat, Nov 14, 2015 at 10:52 AM, Kim-Ee Yeoh <ky3@atamo.com> wrote:
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:
 
   IO System.IO.Handle
-> (System.IO.Handle -> IO Data.ByteString.ByteString)
-> Data.ByteString.ByteString

To elaborate, the error message comes from the compiler choking on the monadic bind (>>=) that reveals itself in the desugared code.

The (>>=) results from desugaring

   file <- openBinaryFile filename ReadMode

into

   openBinaryFile filename ReadMode >>= \file -> ...

The compiler knows the type signature of (>>=), which wants to see

   IO Handle -> (Handle -> IO ByteString) -> IO ByteString

But the signature of the top-level function insists on

   IO Handle -> (Handle -> IO ByteString) -> ByteString

This is what's the compiler's trying to say.


-- Kim-Ee