biohazard-2.1: bioinformatics support library

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Log

Synopsis

Documentation

class Monad m => MonadLog m where Source #

Monads in which messages can be logged. Any Exception can be logged; it is reported and/or collected, but does not abort any computation.

Methods

logMsg :: Exception e => Level -> e -> m () Source #

Logs a message at a given level. Depending on settings, the message may be printed and/or stored.

logString_ :: String -> m () Source #

Updates the progress indicator. The message should not contain line feeds, as it is intended to fit on one line and be overwritten repeatedly.

logStringLn :: String -> m () Source #

Prints a progress indication. The message should persist on the user's terminal.

Instances
MonadIO m => MonadLog (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

logMsg :: Exception e => Level -> e -> Logged m () Source #

logString_ :: String -> Logged m () Source #

logStringLn :: String -> Logged m () Source #

(MonadLog m, Monoid w) => MonadLog (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

logMsg :: Exception e => Level -> e -> RWST r w s m () Source #

logString_ :: String -> RWST r w s m () Source #

logStringLn :: String -> RWST r w s m () Source #

data Level Source #

Severity levels for logging.

Constructors

Debug

Message only useful for debugging. Typically ignored.

Info

Purely informative message, e.g. progress reports. Sometimes printed.

Notice

Something remarkable, but harmless. Sometimes printed, but not collected.

Warning

Something unexpected, but usually not a problem. Typically printed, but not collected.

Error

Recoverable error, will normally result in `ExitFailure 1`. Printed and collected.

Instances
Bounded Level Source # 
Instance details

Defined in Control.Monad.Log

Enum Level Source # 
Instance details

Defined in Control.Monad.Log

Eq Level Source # 
Instance details

Defined in Control.Monad.Log

Methods

(==) :: Level -> Level -> Bool #

(/=) :: Level -> Level -> Bool #

Ord Level Source # 
Instance details

Defined in Control.Monad.Log

Methods

compare :: Level -> Level -> Ordering #

(<) :: Level -> Level -> Bool #

(<=) :: Level -> Level -> Bool #

(>) :: Level -> Level -> Bool #

(>=) :: Level -> Level -> Bool #

max :: Level -> Level -> Level #

min :: Level -> Level -> Level #

Show Level Source # 
Instance details

Defined in Control.Monad.Log

Methods

showsPrec :: Int -> Level -> ShowS #

show :: Level -> String #

showList :: [Level] -> ShowS #

Ix Level Source # 
Instance details

Defined in Control.Monad.Log

data LoggingConf Source #

Constructors

LoggingConf 

Fields

Instances
Show LoggingConf Source # 
Instance details

Defined in Control.Monad.Log

newtype Logged m a Source #

Adds logging to any MonadIO type. Warnings are printed to stderr immediately, but we remember whether any were emitted. If so, we exit with an error code. The advantage over WarningT IO is that the warnings are tracked even if the computation exits with an exception. Progress indicators are sent to the controlling terminal, and dicarded if none exists.

Constructors

Logged 

Fields

Instances
MonadTrans Logged Source # 
Instance details

Defined in Control.Monad.Log

Methods

lift :: Monad m => m a -> Logged m a #

MonadTransControl Logged Source # 
Instance details

Defined in Control.Monad.Log

Associated Types

type StT Logged a :: Type #

Methods

liftWith :: Monad m => (Run Logged -> m a) -> Logged m a #

restoreT :: Monad m => m (StT Logged a) -> Logged m a #

MonadBase b m => MonadBase b (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

liftBase :: b α -> Logged m α #

MonadBaseControl b m => MonadBaseControl b (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Associated Types

type StM (Logged m) a :: Type #

Methods

liftBaseWith :: (RunInBase (Logged m) b -> b a) -> Logged m a #

restoreM :: StM (Logged m) a -> Logged m a #

Monad m => Monad (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

(>>=) :: Logged m a -> (a -> Logged m b) -> Logged m b #

(>>) :: Logged m a -> Logged m b -> Logged m b #

return :: a -> Logged m a #

fail :: String -> Logged m a #

Functor m => Functor (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

fmap :: (a -> b) -> Logged m a -> Logged m b #

(<$) :: a -> Logged m b -> Logged m a #

Applicative m => Applicative (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

pure :: a -> Logged m a #

(<*>) :: Logged m (a -> b) -> Logged m a -> Logged m b #

liftA2 :: (a -> b -> c) -> Logged m a -> Logged m b -> Logged m c #

(*>) :: Logged m a -> Logged m b -> Logged m b #

(<*) :: Logged m a -> Logged m b -> Logged m a #

Alternative m => Alternative (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

empty :: Logged m a #

(<|>) :: Logged m a -> Logged m a -> Logged m a #

some :: Logged m a -> Logged m [a] #

many :: Logged m a -> Logged m [a] #

MonadIO m => MonadIO (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

liftIO :: IO a -> Logged m a #

MonadThrow m => MonadThrow (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

throwM :: Exception e => e -> Logged m a #

MonadCatch m => MonadCatch (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

catch :: Exception e => Logged m a -> (e -> Logged m a) -> Logged m a #

MonadMask m => MonadMask (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

mask :: ((forall a. Logged m a -> Logged m a) -> Logged m b) -> Logged m b #

uninterruptibleMask :: ((forall a. Logged m a -> Logged m a) -> Logged m b) -> Logged m b #

generalBracket :: Logged m a -> (a -> ExitCase b -> Logged m c) -> (a -> Logged m b) -> Logged m (b, c) #

PrimMonad m => PrimMonad (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Associated Types

type PrimState (Logged m) :: Type #

Methods

primitive :: (State# (PrimState (Logged m)) -> (#State# (PrimState (Logged m)), a#)) -> Logged m a #

MonadIO m => MonadLog (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

Methods

logMsg :: Exception e => Level -> e -> Logged m () Source #

logString_ :: String -> Logged m () Source #

logStringLn :: String -> Logged m () Source #

MFunctor Logged Source # 
Instance details

Defined in Control.Monad.Log

Methods

hoist :: Monad m => (forall a. m a -> n a) -> Logged m b -> Logged n b #

type StT Logged a Source # 
Instance details

Defined in Control.Monad.Log

type StT Logged a
type PrimState (Logged m) Source # 
Instance details

Defined in Control.Monad.Log

type StM (Logged m) a Source # 
Instance details

Defined in Control.Monad.Log

type StM (Logged m) a

execWithParser_ :: Parser a -> Maybe Version -> Maybe String -> InfoMod (a, LoggingConf) -> (a -> LIO b) -> IO b Source #

General wrapper around main. Runs a command line parser with added standard options (logging and usage related), runs the actual main function, prints collected warnings and caught exceptions, and exits appropriately: `exitWith (ExitFailure 2)` if an exception was caught, exitFailure if there were warnings of sufficient severity, and exitSuccess otherwise.

data PanicCall Source #

An exception than can be thrown when it doesn't seem warranted to define a custom exception. Transports a message.

Constructors

PanicCall String 

panic :: MonadIO m => String -> m a Source #