Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/prelude/IO/HGetContents.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module IO (hGetContents) where

import NHC.Internal (IO(..))
import DHandle
import HGetChar(cHGetChar)

import PreludeBuiltin (_hGetStr)

{-
nhc currently doesn't implement semi-closed handles.
Hence using hGetContents twice for the same handle will lead
to obscure results.
-}

hGetContents            :: Handle -> IO String
hGetContents h           = IO (\world -> Right (cHGetStr h))
{-
 where
  input h = let c = cHGetChar h
            in if c < 0 then
                 []			-- EOF here
               else
                 toEnum c : input h
-}

cHGetStr :: Handle -> [Char]
cHGetStr h = _hGetStr h		-- _hGetStr becomes a special bytecode


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].