@hackage knob0.1
Memory-backed handles
Categories
License
MIT
Maintainer
John Millikin <jmillikin@gmail.com>
Links
Versions
Installation
Dependencies (3)
- base >=4.2 && <5.0
- bytestring >=0.9 && <0.10
- transformers >=0.2 && <0.3 Show all…
Dependents (8)
@hackage/gigaparsec, @hackage/typed-protocols-doc, @hackage/acme-everything, @hackage/rdf4h, @hackage/simpleirc, @hackage/haskell-tools-cli, Show all…
Create memory-backed IO.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)