-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Memory-backed handles -- -- Create memory-backed Handles, referencing virtual files. This -- is mostly useful for testing Handle-based APIs without having -- to interact with the filesystem. -- --
-- import Data.ByteString (pack)
-- import Data.Knob
-- import System.IO
--
-- main = do
-- knob <- newKnob (pack [])
-- h <- newFileHandle knob "test.txt" WriteMode
-- hPutStrLn h "Hello world!"
-- hClose h
-- bytes <- Data.Knob.getContents knob
-- putStrLn ("Wrote bytes: " ++ show bytes)
--
@package knob
@version 0.2
-- | Create memory‐backed Handles, referencing virtual files. This
-- is mostly useful for testing Handle‐based APIs without having
-- to interact with the filesystem.
--
--
-- import Data.ByteString (pack)
-- import Data.Knob
-- import System.IO
--
-- main = do
-- knob <- newKnob (pack [])
-- h <- newFileHandle knob "test.txt" WriteMode
-- hPutStrLn h "Hello world!"
-- hClose h
-- bytes <- Data.Knob.getContents knob
-- putStrLn ("Wrote bytes: " ++ show bytes)
--
module Data.Knob
-- | A knob is a basic virtual file, which contains a byte buffer. A knob
-- can have multiple Handles open to it, each of which behaves
-- like a standard file handle.
--
-- Use getContents and setContents to inspect and modify
-- the knob's byte buffer.
data Knob
newKnob :: MonadIO m => ByteString -> m Knob
getContents :: MonadIO m => Knob -> m ByteString
setContents :: MonadIO m => Knob -> ByteString -> m ()
-- | Create a new Handle pointing to a Knob. This handle
-- behaves like a file-backed handle for most purposes.
newFileHandle :: MonadIO m => Knob -> String -> IOMode -> m Handle
-- | See newFileHandle.
withFileHandle :: MonadIO m => Knob -> String -> IOMode -> (Handle -> IO a) -> m a
instance GHC.IO.Device.IODevice Data.Knob.Device
instance GHC.IO.Device.RawIO Data.Knob.Device
instance GHC.IO.BufferedIO.BufferedIO Data.Knob.Device