chatty-0.7.0.0: Some monad transformers and typeclasses for abstraction of global dependencies.

Safe HaskellSafe
LanguageHaskell2010

Text.Chatty.Printer

Description

Provides a typeclass for all monads that may print text.

Synopsis

Documentation

class Monad m => ChPrinter m where Source

A typeclass for all monads that may output strings.

Minimal complete definition

mprint

Methods

mprint :: String -> m () Source

Just print it!

mnoecho :: String -> m () Source

Print it, except you are IO.

mflush :: m () Source

Flush the buffer.

mnomask :: String -> m () Source

Alternative to mprint that does not mask any characters (depends on the carrier).

newtype DeafT m a Source

DeafT discards all output (much like >/dev/null in the shell)

Constructors

Deaf 

Fields

runDeafT :: m a
 

newtype OutRedirT m a Source

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

Constructors

OutRedir 

Fields

runOutRedirT :: Handle -> m a
 

type OutRedir = OutRedirT IO Source

OutRedirT on a blank IO monad

newtype RecorderT m a Source

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

Constructors

Recorder 

Fields

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

newtype Replayable Source

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

Constructors

Replayable [String] 

replay :: Replayable -> String Source

Replay a recorder state in a pure context.

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 :: ChPrinter m => String -> m () Source

Line-terminating alternative to mprint

mnomaskLn :: ChPrinter m => String -> m () Source

Line-terminating alternative to mnomask

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 where Source

Class for all redirection targets.

Minimal complete definition

(.>.)

Methods

(.>.) :: (Functor m, MonadIO m, ChPrinter (mt m)) => mt m a -> t -> m r Source

Overwriting redirection.

(.>>.) :: (Functor m, MonadIO m, ChPrinter (mt m)) => mt m a -> t -> m r Source

Appending redirection.