| Copyright | © 2016 All rights reserved. |
|---|---|
| License | GPL-3 |
| Maintainer | Evan Cofsky <evan@theunixman.com> |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
IO
Description
- putStr :: (MonadIO m, Printable p) => p -> m ()
- putStrLn :: (MonadIO m, Printable p) => p -> m ()
- managed :: (forall r. (a -> IO r) -> IO r) -> Managed a
- data Managed a :: * -> *
- class MonadIO m => MonadManaged m where
- runManaged :: Managed () -> IO ()
- data TempFile
- tfPath :: Lens' TempFile AbsFile
- tfHandle :: Lens' TempFile Handle
- tempFile :: AbsDir -> RelFile -> Managed TempFile
- class Monad m => MonadIO m where
- liftIO :: MonadIO m => forall a. IO a -> m a
- hSeek :: Handle -> SeekMode -> Integer -> IO ()
- data SeekMode :: *
- file :: AbsRelFile -> IOMode -> Managed Handle
Documentation
A managed resource that you acquire using with
class MonadIO m => MonadManaged m where #
You can embed a Managed action within any Monad that implements
MonadManaged by using the using function
All instances must obey the following two laws:
using (return x) = return x using (m >>= f) = using m >>= \x -> using (f x)
Minimal complete definition
Instances
| MonadManaged Managed | |
| MonadManaged m => MonadManaged (MaybeT m) | |
| MonadManaged m => MonadManaged (IdentityT * m) | |
| (Monoid w, MonadManaged m) => MonadManaged (WriterT w m) | |
| (Monoid w, MonadManaged m) => MonadManaged (WriterT w m) | |
| MonadManaged m => MonadManaged (StateT s m) | |
| MonadManaged m => MonadManaged (StateT s m) | |
| MonadManaged m => MonadManaged (ExceptT e m) | |
| MonadManaged m => MonadManaged (ReaderT * r m) | |
| MonadManaged m => MonadManaged (ContT * r m) | |
| (Monoid w, MonadManaged m) => MonadManaged (RWST r w s m) | |
| (Monoid w, MonadManaged m) => MonadManaged (RWST r w s m) | |
runManaged :: Managed () -> IO () #
Run a Managed computation, enforcing that no acquired resources leak
class Monad m => MonadIO m where #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Minimal complete definition
Instances
| MonadIO IO | |
| MonadIO Managed | |
| MonadIO m => MonadIO (MaybeT m) | |
| MonadIO m => MonadIO (ListT m) | |
| MonadIO m => MonadIO (ResourceT m) | |
| MonadIO m => MonadIO (IdentityT * m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| MonadIO m => MonadIO (StateT s m) | |
| MonadIO m => MonadIO (StateT s m) | |
| (Error e, MonadIO m) => MonadIO (ErrorT e m) | |
| (Functor f, MonadIO m) => MonadIO (FreeT f m) | |
| MonadIO m => MonadIO (ExceptT e m) | |
| MonadIO m => MonadIO (ReaderT * r m) | |
| MonadIO m => MonadIO (ContT * r m) | |
| (Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
| (Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
hSeek :: Handle -> SeekMode -> Integer -> IO () #
Computation hSeek hdl mode i sets the position of handle
hdl depending on mode.
The offset i is given in terms of 8-bit bytes.
If hdl is block- or line-buffered, then seeking to a position which is not
in the current buffer will first cause any items in the output buffer to be
written to the device, and then cause the input buffer to be discarded.
Some handles may not be seekable (see hIsSeekable), or only support a
subset of the possible positioning operations (for instance, it may only
be possible to seek to the end of a tape, or to a positive offset from
the beginning or current position).
It is not possible to set a negative I/O position, or for
a physical file, an I/O position beyond the current end-of-file.
This operation may fail with:
isIllegalOperationErrorif the Handle is not seekable, or does not support the requested seek mode.isPermissionErrorif a system resource limit would be exceeded.
A mode that determines the effect of hSeek hdl mode i.
Constructors
| AbsoluteSeek | the position of |
| RelativeSeek | the position of |
| SeekFromEnd | the position of |