• code Haskell
    hPutStr :: Handle -> BL.ByteString -> IO ()
    hPutStr hdl lbs = wantWritableHandle "Data.ByteString.Lazy.hPutStr" hdl $ \hdl__ ->
      BL.foldrChunks (go hdl__) (commit hdl__) lbs
     where
      go hdl__ (S.PS ps s l) rest = do
       unless (l == 0) $ withForeignPtr ps $ \p -> do
        _ <- bufWrite hdl__ (p `plusPtr` s) l True
        pure ()
       rest
      commit hdl__ =
       case haBufferMode hdl__ of
        BlockBuffering _   -> do return ()
        _line_or_no_buffering -> do flushWriteBuffer hdl__
                      return ()

Replies (0)