Skip to content

Instantly share code, notes, and snippets.

@master-q
Created July 12, 2012 06:40
Show Gist options
  • Save master-q/3096308 to your computer and use it in GitHub Desktop.
Save master-q/3096308 to your computer and use it in GitHub Desktop.
HaskellのflushStdHandles関数のコールグラフ (間違い?)
flushStdHandles
-> hFlush stdout
-> wantWritableHandle "hFlush" stdout flushWriteBuffer
let (FileHandle _ m) = stdout -- mはMVar
-> wantWritableHandle' "hFlush" stdout m flushWriteBuffer
let act = checkWritableHandle flushWriteBuffer
-> withHandle_' "hFlush" stdout m act
let act' = \h_ -> {do a <- act h_; return (h_,a)}
-> withHandle' "hFlush" stdout m act'
-> (h',v) <- do_operation "hFlush" h act' m
h_ <- takeMVar m
-> checkHandleInvariants h_
-> act' h_
-> checkWritableHandle
-> flushWriteBuffer
-> flushByteWriteBuffer
bbuf <- readIORef haByteBuffer
-> bbuf' <- Buffered.flushWriteBuffer haDevice bbuf
-> writeBuf' haDevice buf
-> writeBuf haDevice buf
let bytes = bufferElems bbuf
let f = \ptr -> IODevice.write haDevice (ptr `plusPtr` bufL bbuf) bytes
withBuffer bbuf f
return bbuf{ bufL=0, bufR=0 }
writeIORef haByteBuffer bbuf'
-> checkHandleInvariants h'
putMVar m h'
return v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment