| Copyright | (c) 2018-2020 Kowainik 2021-2025 Co-Log |
|---|---|
| License | MPL-2.0 |
| Maintainer | Co-Log <xrom.xkov@gmail.com> |
| Stability | Stable |
| Portability | Portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Colog.Core.Class
Contents
Description
Provides type class for values that has access to LogAction.
Synopsis
- class HasLog env msg m where
- getLogAction :: env -> LogAction m msg
- setLogAction :: LogAction m msg -> env -> env
- overLogAction :: (LogAction m msg -> LogAction m msg) -> env -> env
- logActionL :: Lens' env (LogAction m msg)
- type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s
Documentation
class HasLog env msg m where Source #
This types class contains simple pair of getter-setter and related
functions.
It also provides the useful lens logActionL with the default implementation using type
class methods. The default one could be easily overritten under your instances.
Every instance of the this typeclass should satisfy the following laws:
- Set-Get:
getLogAction(setLogActionl env) ≡ l - Get-Set:
setLogAction(getLogActionenv) env ≡ env - Set-Set:
setLogActionl2 (setLogActionl1 env) ≡setLogActionl2 env - Set-Over:
overLogActionf env ≡setLogAction(f $getLogActionenv) env
Minimal complete definition
Methods
getLogAction :: env -> LogAction m msg Source #
Extracts LogAction from the environment.
setLogAction :: LogAction m msg -> env -> env Source #
Sets LogAction to the given one inside the environment.
overLogAction :: (LogAction m msg -> LogAction m msg) -> env -> env Source #
Applies function to the LogAction inside the environment.
logActionL :: Lens' env (LogAction m msg) Source #
Lens for LogAction inside the environment.
Instances
| HasLog (LogAction m msg) msg m Source # | |
Defined in Colog.Core.Class Methods getLogAction :: LogAction m msg -> LogAction m msg Source # setLogAction :: LogAction m msg -> LogAction m msg -> LogAction m msg Source # overLogAction :: (LogAction m msg -> LogAction m msg) -> LogAction m msg -> LogAction m msg Source # logActionL :: Lens' (LogAction m msg) (LogAction m msg) Source # | |
Lens
To keep co-log-core a lightweight library it was decided to introduce local
Lens' type alias as it doesn't harm.