| Copyright | (c) 2019-2020 Kowainik | 
|---|---|
| License | MPL-2.0 | 
| Maintainer | Kowainik <xrom.xkov@gmail.com> | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Colog.Polysemy.Effect
Description
This module contains logging effect which can be interpreted in terms of
LogAction from the co-log-core package.
Synopsis
- data Log (msg :: Type) (m :: Type -> Type) (a :: Type) where
- log :: forall msg r. Member (Log msg) r => msg -> Sem r ()
- type LogActionSem r msg = LogAction (Sem r) msg
- runLogActionSem :: forall msg r a. LogActionSem r msg -> Sem (Log msg ': r) a -> Sem r a
- runLogAction :: forall m msg r a. Member (Embed m) r => LogAction m msg -> Sem (Log msg ': r) a -> Sem r a
- runLogAsTrace :: forall r a. Member Trace r => Sem (Log String ': r) a -> Sem r a
- runLogAsOutput :: forall msg r a. Member (Output msg) r => Sem (Log msg ': r) a -> Sem r a
- runTraceAsLog :: forall r a. Member (Log String) r => Sem (Trace ': r) a -> Sem r a
- runOutputAsLog :: forall msg r a. Member (Log msg) r => Sem (Output msg ': r) a -> Sem r a
Effect
data Log (msg :: Type) (m :: Type -> Type) (a :: Type) where Source #
Effect responsible for logging messages of type msg. Has similar
structure to LogAction.
You can think of this effect in the following way in terms of the existing
effects in polysemy:
Actions
Direct usages
type LogActionSem r msg = LogAction (Sem r) msg Source #
LogAction that works directly with the Sem monad.
Since: 0.0.1.0
runLogActionSem :: forall msg r a. LogActionSem r msg -> Sem (Log msg ': r) a -> Sem r a Source #
Run Sem action with the corresponding LogActionSem. If you
have plain LogAction that works with some monad m, use
runLogAction instead.
Since: 0.0.1.0
Interpretations
runLogAction :: forall m msg r a. Member (Embed m) r => LogAction m msg -> Sem (Log msg ': r) a -> Sem r a Source #
Run a Log effect in terms of the given LogAction. The idea behind this
function is the following: if you have LogAction m msgLog. However, this is only possible
if you also have Lift mm.
This function allows to use extensible effects provided by the polysemy
library with logging provided by co-log. You can construct LogAction
independently and then just pass to this function to tell how to log messages.
Several examples:
- runLogActionmempty- Logeffect by ignoring all messages.
- runLogAction- logStringStdout- Logeffect by allowing to log- Stringto- stdout.