co-log-core-0.2.1.1: Composable Contravariant Comonadic Logging Library
Copyright(c) 2018-2020 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Colog.Core.Class

Contents

Description

Provides type class for values that has access to LogAction.

Synopsis

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:

  1. Set-Get: getLogAction (setLogAction l env) ≡ l
  2. Get-Set: setLogAction (getLogAction env) env ≡ env
  3. Set-Set: setLogAction l2 (setLogAction l1 env) ≡ setLogAction l2 env
  4. Set-Over: overLogAction f env ≡ setLogAction (f $ getLogAction env) env

Minimal complete definition

logActionL | getLogAction, (setLogAction | overLogAction)

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

Instances details
HasLog (LogAction m msg) msg m Source # 
Instance details

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.

type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s Source #

The monomorphic lenses which don't change the type of the container (or of the value inside).