About

Metadata

  • Last updated , by ncfavier
  • License MIT
  • Categories Systems Programming
  • Maintained by: Naïm Favier <n@monade.li>

  • Lottery factor: 0

Links

Installation

Tested Compilers

  1. 9.2.1
  2. 9.0.2

Readme

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)