Skip to content

Commit

Permalink
[co-log#138] Add higher-order transformation function
Browse files Browse the repository at this point in the history
  • Loading branch information
jiribenes committed Oct 7, 2019
1 parent 63684ba commit 1a89546
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion co-log-core/src/Colog/Core/Action.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}

{- |
Copyright: (c) 2018-2019 Kowainik
Expand Down Expand Up @@ -48,6 +49,9 @@ module Colog.Core.Action
, (<<=)
, duplicate
, multiplicate

-- * Higher-order combinators
, hoistLogAction
) where

import Control.Monad (when, (>=>))
Expand Down Expand Up @@ -575,3 +579,10 @@ multiplicate (LogAction l) = LogAction $ \msgs -> l (fold msgs)
{-# INLINE multiplicate #-}
{-# SPECIALIZE multiplicate :: Monoid msg => LogAction m msg -> LogAction m [msg] #-}
{-# SPECIALIZE multiplicate :: Monoid msg => LogAction m msg -> LogAction m (NonEmpty msg) #-}

{- | Allows changing the internal monadic action -}
hoistLogAction
:: (forall x. m x -> n x)
-> LogAction m a
-> LogAction n a
hoistLogAction f (LogAction l) = LogAction (f . l)

0 comments on commit 1a89546

Please sign in to comment.