chatty-0.2.0.0: Some monad transformers and typeclasses to simplify I/O on a transformer stack.

Safe HaskellSafe-Inferred

Text.Chatty.Printer

Synopsis

Documentation

class Monad m => MonadPrinter m whereSource

A typeclass for all monads that may output strings.

Methods

mprint :: String -> m ()Source

Just print it!

mnoecho :: String -> m ()Source

Print it, except you are IO.

mflush :: m ()Source

Flush the buffer.

newtype DeafT m a Source

DeafT discards all output (much like >devnull in the shell)

Constructors

Deaf 

Fields

runDeafT :: m a
 

newtype OutRedirT m a Source

OutRedirT redirects all output to a given handle (much like >filename in the shell)

Constructors

OutRedir 

Fields

runOutRedirT' :: Handle -> m (a, Handle)
 

type OutRedir = OutRedirT IOSource

OutRedirT on a blank IO monad

runOutRedirT :: Functor m => OutRedirT m a -> Handle -> m aSource

Run OutRedirT with a handle

runOutRedir :: OutRedir a -> Handle -> IO aSource

Run OutRedir with a handle

runOutRedirFT :: (Functor m, MonadIO m) => OutRedirT m a -> FilePath -> IOMode -> m aSource

Run OutRedirT with a filename

runOutRedirF :: OutRedir a -> FilePath -> IOMode -> IO aSource

Run OutRedir with a filename

newtype RecorderT m a Source

RecorderT catches all output (much like VAR=$(...) in the shell)

Constructors

Recorder 

Fields

runRecorderT' :: [String] -> m (a, [String])
 

type Recorder = RecorderT IdentitySource

RecorderT on identity

newtype Replayable Source

The recorder state. Use this together with replay, replayM or replay_

Constructors

Replayable [String] 

replayM :: Monad m => m Replayable -> m StringSource

Replay a recorder state inside a monad.

replay :: Replayable -> StringSource

Replay a recorder state in a pure context.

replay_ :: Monad m => RecorderT m StringSource

Replay the current recorder state without leaving the recorder.

runRecorder :: Recorder a -> (a, Replayable)Source

Run Recorder and also return its state.

runRecorderT :: (Functor m, Monad m) => RecorderT m a -> m (a, Replayable)Source

Run RecorderT and also return its state.

mprintLn :: MonadPrinter m => String -> m ()Source

Line-terminating alternative to mprint

data DiscardO Source

Redirection target that discards input.

Constructors

DiscardO 

data RecordO Source

Redirection target that records input.

Constructors

RecordO 

class RedirectionTarget t mt a r | t -> mt, t a -> r whereSource

Class for all redirection targets.

Methods

(.>.) :: (Functor m, MonadIO m, MonadPrinter (mt m)) => mt m a -> t -> m rSource

Overwriting redirection.

(.>>.) :: (Functor m, MonadIO m, MonadPrinter (mt m)) => mt m a -> t -> m rSource

Appending redirection.