Copyright | (c) Anton Gushcha, 2015-2016 |
---|---|
License | BSD3 |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The module contains all API for Gore&Ash logging module. The module doesn't depends on others core modules and could be place in any place in game monad stack.
The core module is pure on it first phase and could be used with Identity
end monad.
See ModuleStack
documentation.
Example of embedding:
-- | Application monad is monad stack build from given list of modules over base monad (IO) type AppStack = ModuleStack [LoggingT, ... other modules ... ] IO newtype AppState = AppState (ModuleState AppStack) deriving (Generic) instance NFData AppState -- | Wrapper around type family newtype AppMonad a = AppMonad (AppStack a) deriving (Functor, Applicative, Monad, MonadFix, MonadIO, LoggingMonad, ... other modules monads ... ) instance GameModule AppMonad AppState where type ModuleState AppMonad = AppState runModule (AppMonad m) (AppState s) = do (a, s') <- runModule m s return (a, AppState s') newModuleState = AppState $ newModuleState withModule _ = withModule (Proxy :: Proxy AppStack) cleanupModule (AppState s) = cleanupModule s -- | Arrow that is build over the monad stack type AppWire a b = GameWire AppMonad a b
playerActor :: ActorMonad m => (PlayerId -> Player) -> GameActor m PlayerId Game Player playerActor initialPlayer = makeActor $ i -> stateWire (initialPlayer i) $ mainController i where mainController i = proc (g, p) -> do
@
- data LoggingState s
- data LoggingT s m a
- class Monad m => LoggingMonad m where
- logA :: LoggingMonad m => GameWire m Text ()
- logALn :: LoggingMonad m => GameWire m Text ()
- logE :: LoggingMonad m => GameWire m (Event Text) (Event ())
- logELn :: LoggingMonad m => GameWire m (Event Text) (Event ())
- logInfoA :: LoggingMonad m => GameWire m Text ()
- logWarnA :: LoggingMonad m => GameWire m Text ()
- logErrorA :: LoggingMonad m => GameWire m Text ()
- logInfoE :: LoggingMonad m => GameWire m (Event Text) (Event ())
- logWarnE :: LoggingMonad m => GameWire m (Event Text) (Event ())
- logErrorE :: LoggingMonad m => GameWire m (Event Text) (Event ())
- traceEvent :: LoggingMonad m => (a -> Text) -> GameWire m (Event a) (Event ())
- traceEventShow :: (TextShow a, LoggingMonad m) => GameWire m (Event a) (Event ())
Low-level API
data LoggingState s Source
Inner state of logger.
s
- next state, states of modules are chained via nesting
Generic (LoggingState s) Source | |
NFData s => NFData (LoggingState s) Source | |
Monad m => MonadState (LoggingState s) (LoggingT s m) | |
type Rep (LoggingState s) Source |
Monad transformer of logging core module.
s
- - State of next core module in modules chain;
m
- - Next monad in modules monad stack;
a
- - Type of result value;
How to embed module:
type AppStack = ModuleStack [LoggingT, ... other modules ... ] IO newtype AppMonad a = AppMonad (AppStack a) deriving (Functor, Applicative, Monad, MonadFix, MonadIO, LoggingMonad)
The module is pure within first phase (see ModuleStack
docs) and could be used
with Identity
end monad.
MonadBase IO m => MonadBase IO (LoggingT s m) Source | |
MonadError e m => MonadError e (LoggingT s m) Source | |
MonadTrans (LoggingT s) Source | |
Monad m => MonadState (LoggingState s) (LoggingT s m) Source | |
Monad m => Monad (LoggingT s m) Source | |
Functor m => Functor (LoggingT s m) Source | |
MonadFix m => MonadFix (LoggingT s m) Source | |
Monad m => Applicative (LoggingT s m) Source | |
MonadIO m => MonadIO (LoggingT s m) Source | |
MonadThrow m => MonadThrow (LoggingT s m) Source | |
MonadMask m => MonadMask (LoggingT s m) Source | |
MonadCatch m => MonadCatch (LoggingT s m) Source | |
MonadResource m => MonadResource (LoggingT s m) Source | |
Monad m => LoggingMonad (LoggingT s m) Source | |
type ModuleState (LoggingT s m) = LoggingState s Source |
class Monad m => LoggingMonad m where Source
Low level API for module
putMsgM :: Text -> m () Source
Put message to the console.
putMsgLnM :: Text -> m () Source
Put message and new line to the console.
(Monad (mt m), LoggingMonad m, MonadTrans mt) => LoggingMonad (mt m) Source | |
Monad m => LoggingMonad (LoggingT s m) Source |
Arrow API
logA :: LoggingMonad m => GameWire m Text () Source
Put message to console on every frame without newline
logALn :: LoggingMonad m => GameWire m Text () Source
Put message to console on every frame
logE :: LoggingMonad m => GameWire m (Event Text) (Event ()) Source
Put message to console on event without newline
logELn :: LoggingMonad m => GameWire m (Event Text) (Event ()) Source
Put message to console on event
Every frame
logInfoA :: LoggingMonad m => GameWire m Text () Source
Put info msg to console
logWarnA :: LoggingMonad m => GameWire m Text () Source
Put warn msg to console
logErrorA :: LoggingMonad m => GameWire m Text () Source
Put error msg to console
Event based
logInfoE :: LoggingMonad m => GameWire m (Event Text) (Event ()) Source
Put info msg to console on event
logWarnE :: LoggingMonad m => GameWire m (Event Text) (Event ()) Source
Put warn msg to console on event
logErrorE :: LoggingMonad m => GameWire m (Event Text) (Event ()) Source
Put error msg to console on event
Event tracing
traceEvent :: LoggingMonad m => (a -> Text) -> GameWire m (Event a) (Event ()) Source
Prints event with given function
traceEventShow :: (TextShow a, LoggingMonad m) => GameWire m (Event a) (Event ()) Source
Prints event