| 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 | None |
| Language | Haskell2010 |
Colog.Core.Class
Contents
Description
Provides type class for values that has access to LogAction.
Synopsis
- class HasLog env msg (m :: Type -> Type) 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 :: Type -> Type). Functor f => (a -> f a) -> s -> f s
Documentation
class HasLog env msg (m :: Type -> Type) where #
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 #
Extracts LogAction from the environment.
setLogAction :: LogAction m msg -> env -> env #
Sets LogAction to the given one inside the environment.
overLogAction :: (LogAction m msg -> LogAction m msg) -> env -> env #
Applies function to the LogAction inside the environment.
logActionL :: Lens' env (LogAction m msg) #
Lens for LogAction inside the environment.
Instances
| HasLog (LogAction m msg) msg m # | |
Defined in Colog.Core.Class Methods getLogAction :: LogAction m msg -> LogAction m msg # setLogAction :: LogAction m msg -> LogAction m msg -> LogAction m msg # overLogAction :: (LogAction m msg -> LogAction m msg) -> LogAction m msg -> LogAction m msg # logActionL :: Lens' (LogAction m msg) (LogAction m msg) # | |
Lens
To keep co-log-core a lightweight library it was decided to introduce local
Lens' type alias as it doesn't harm.