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

Safe HaskellSafe-Inferred
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, Handle)
 

type OutRedir = OutRedirT IO Source

OutRedirT on a blank IO monad

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

Run OutRedirT with a Handle

newtype Replayable Source

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

Constructors

Replayable [String] 

replayM :: Monad m => m Replayable -> m String Source

Replay a recorder state inside a Monad.

replay :: Replayable -> String Source

Replay a recorder state in a pure context.

replay_ :: Monad m => RecorderT m String Source

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 :: 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.