 <p>I just wrote a library which provides this, called "knob" [<a href="http://hackage.haskell.org/package/knob">hackage</a>]. You can use it to create <code>Handle</code>s which reference/modify a <code>ByteString</code>:</p> <pre><code>import Data.ByteString (pack) import Data.Knob import System.IO main = do knob &lt;- newKnob (pack []) h &lt;- newFileHandle knob "test.txt" WriteMode hPutStrLn h "Hello world!" hClose h bytes &lt;- Data.Knob.getContents knob putStrLn ("Wrote bytes: " ++ show bytes) </code></pre>