Code below
getSpareBuffer :: Handle__ -> IO (BufferMode, CharBuffer) getSpareBuffer Handle__{haCharBuffer=ref, haBuffers=spare_ref, haBufferMode=mode} = do case mode of NoBuffering -> return (mode, error "no buffer!") _ -> do bufs <- readIORef spare_ref buf <- readIORef ref case bufs of BufferListCons b rest -> do writeIORef spare_ref rest return ( mode, emptyBuffer b (bufSize buf) WriteBuffer) BufferListNil -> do new_buf <- newCharBuffer (bufSize buf) WriteBuffer return (mode, new_buf)
is the source code of the GHC. I want to know why the author of this code uses curly braces instead of arguments. And how the variables haCharBuffer, haBuffers, haBufferMode take values โโfrom ref, spare_ref and mode. These values โโare not defined. The code file is ghc-7.4.1 \ libraries \ base \ GHC \ IO \ Handle \ Text.hs
Another piece of code from the GHC that needs clarification is the following:
flushByteWriteBuffer :: Handle__ -> IO () flushByteWriteBuffer h_@Handle __{..} = do bbuf <- readIORef haByteBuffer when (not (isEmptyBuffer bbuf)) $ do bbuf' <- Buffered.flushWriteBuffer haDevice bbuf writeIORef haByteBuffer bbuf'
In the ghc-7.4.1 code file \ libraries \ base \ GHC \ IO \ Handle \ Internals.hs What is the use of dots inside curly braces?
thanks
source share