pipes-safe-1.2.0: Safety for the pipes ecosystem

Safe HaskellSafe-Inferred

Control.Proxy.Safe.Prelude

Contents

Description

Prelude of proxies providing simple resource management features

Synopsis

Handle allocation

withFileSource

Arguments

:: (Monad m, Proxy p) 
=> (forall x. SafeIO x -> m x)

Monad morphism

-> FilePath

File

-> IOMode

IO Mode

-> (Handle -> ExceptionP p a' a b' b m r)

Continuation

-> ExceptionP p a' a b' b m r 

Safely allocate a Handle within a managed Proxy

String I/O

Note that Strings are very inefficient, and I will release future separate packages with ByteString and Text operations. I only provide these to allow users to test simple I/O without requiring any additional library dependencies.

readFileS :: Proxy p => FilePath -> () -> Producer (ExceptionP p) String SafeIO ()Source

Read from a file, lazily opening the Handle and automatically closing it afterwards

writeFileD :: Proxy p => FilePath -> x -> ExceptionP p x String x String SafeIO rSource

Write to a file, lazily opening the Handle and automatically closing it afterwards