on master help sign in
Static argument transformation of hGetLineLoop

--HG-- extra : convert_revision : fc4ebcbc4b756aef699d249aada4d3a8ec70e3bb

commit839b12ea6a30f367e6c93cf15028424996bff276 authorBryan O'Sullivan <bos@serpentine.com> dateWed 8 Sep 2010, 05:14 (16 years ago) parentf3b297d
1 file changed+3−2
Data/Text/IO/Internal.hs+3−2
Data/Text/IO/Internal.hs+3−2
@@ -44,7 +44,8 @@ hGetLineWith f h = wantReadableHandle_ "hGetLine" h go
4444 go hh@Handle__{..} = readIORef haCharBuffer >>= fmap f . hGetLineLoop hh []
4545
4646hGetLineLoop :: Handle__ -> [Text] -> CharBuffer -> IO [Text]
47−hGetLineLoop hh@Handle__{..} ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do
47+hGetLineLoop hh@Handle__{..} = go where
48+ go ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do
4849 let findEOL raw r | r == w = return (False, w)
4950 | otherwise = do
5051 (c,r') <- readCharBuf raw r
@@ -76,7 +77,7 @@ hGetLineLoop hh@Handle__{..} ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do
7677 if null str
7778 then ioe_EOF
7879 else return str
79− Just new_buf -> hGetLineLoop hh (t:ts) new_buf
80+ Just new_buf -> go (t:ts) new_buf
8081
8182-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
8283maybeFillReadBuffer :: Handle__ -> CharBuffer -> IO (Maybe CharBuffer)