Skip to content

Commit 491e731

Browse files
SanchayanMaityvrom911
authored andcommitted
Write default implementation to getLogAction via logActionL (#153)
Signed-off-by: Sanchayan Maity <[email protected]>
1 parent d899675 commit 491e731

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

co-log-core/src/Colog/Core/Class.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Colog.Core.Class
1919
) where
2020

2121
import Colog.Core.Action (LogAction)
22-
22+
import Data.Functor.Const (Const (..))
2323

2424
-- to inline lens better
2525
{- HLINT ignore "Redundant lambda" -}
@@ -37,10 +37,12 @@ Every instance of the this typeclass should satisfy the following laws:
3737
4. __Set-Over:__ @'overLogAction' f env ≡ 'setLogAction' (f $ 'getLogAction' env) env@
3838
-}
3939
class HasLog env msg m where
40-
{-# MINIMAL getLogAction, (setLogAction | overLogAction) #-}
40+
{-# MINIMAL logActionL | (getLogAction , (setLogAction | overLogAction)) #-}
4141

4242
-- | Extracts 'LogAction' from the environment.
4343
getLogAction :: env -> LogAction m msg
44+
getLogAction = getConst . logActionL Const
45+
{-# INLINE getLogAction #-}
4446

4547
-- | Sets 'LogAction' to the given one inside the environment.
4648
setLogAction :: LogAction m msg -> env -> env

0 commit comments

Comments
 (0)