Safe Haskell | Safe-Inferred |
---|
Prelude of proxies providing simple resource management features
- withFile :: (Monad m, Proxy p) => (forall x. SafeIO x -> m x) -> FilePath -> IOMode -> (Handle -> ExceptionP p a' a b' b m r) -> ExceptionP p a' a b' b m r
- readFileS :: Proxy p => FilePath -> () -> Producer (ExceptionP p) String SafeIO ()
- writeFileD :: Proxy p => FilePath -> x -> ExceptionP p x String x String SafeIO r
Handle allocation
:: (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 |
String I/O
Note that String
s 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