| Copyright | (c) 2019 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 ()
- runLogAction :: forall m msg r a. Member (Lift 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
Interpretations
runLogAction :: forall m msg r a. Member (Lift 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 then you can use this
action to tell how to io interpret effect LogAction m msgLog. However, this is only possible
if you also have effect because running log action requires access to
monad 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:
: interprets therunLogActionmemptyLogeffect by ignoring all messages.: interpretsrunLogActionlogStringStdoutLogeffect by allowing to logStringtostdout.