Skip to content

Commit

Permalink
Tweak MonadUnliftIO TraceT instance
Browse files Browse the repository at this point in the history
The new definition should be compatible both with unliftio <0.2 and
>=0.2.

Also add condition around `<>` import to avoid warnings in recent
versions of GHC.
  • Loading branch information
mtth committed Apr 6, 2020
1 parent 48fcc39 commit 86aa9ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright Matthieu Monsch (c) 2019
Copyright Matthieu Monsch (c) 2019-2020

All rights reserved.

Expand Down Expand Up @@ -27,4 +27,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 4 additions & 4 deletions src/Control/Monad/Trace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import Control.Monad.Trace.Internal

import Control.Applicative ((<|>))
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Reader (ReaderT(..), ask, asks, local, runReaderT)
import Control.Monad.Reader (ReaderT(ReaderT), ask, asks, local, runReaderT)
import Control.Monad.Reader.Class (MonadReader)
import Control.Monad.Trans.Class (MonadTrans(..))
import Control.Monad.Trans.Class (MonadTrans, lift)
import qualified Data.Aeson as JSON
import Data.Foldable (for_)
import Data.List (sortOn)
Expand All @@ -41,7 +41,7 @@ import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
import Data.Time.Clock (NominalDiffTime)
import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime)
import UnliftIO (MonadUnliftIO, UnliftIO(..), askUnliftIO, withUnliftIO)
import UnliftIO (MonadUnliftIO, withRunInIO)
import UnliftIO.Exception (finally)
import UnliftIO.STM (TChan, TVar, atomically, modifyTVar', newTChanIO, newTVarIO, readTVar, writeTChan, writeTVar)

Expand Down Expand Up @@ -161,7 +161,7 @@ instance MonadUnliftIO m => MonadTrace (TraceT m) where
atomically $ modifyTVar' tv ((time, key, val) :)

instance MonadUnliftIO m => MonadUnliftIO (TraceT m) where
askUnliftIO = TraceT $ withUnliftIO $ \u -> pure (UnliftIO (unliftIO u . traceTReader ))
withRunInIO inner = TraceT $ withRunInIO $ \run -> inner (run . traceTReader)

-- | Trace an action, sampling its generated spans. This method is thread-safe and can be used to
-- trace multiple actions concurrently.
Expand Down
4 changes: 4 additions & 0 deletions src/Monitor/Tracing/Zipkin.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -57,6 +58,9 @@ import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes, fromMaybe, listToMaybe, maybeToList)
import Data.Monoid (Endo(..))
#if !MIN_VERSION_base(4, 11, 0)
import Data.Semigroup ((<>))
#endif
import Data.Set (Set)
import Data.String (IsString(..))
import Data.Text (Text)
Expand Down
14 changes: 5 additions & 9 deletions tracing.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@ cabal-version: 1.12
name: tracing
version: 0.0.5.1
synopsis: Distributed tracing
category: Web
homepage: https://github.com/mtth/tracing
description:
An OpenTracing-compliant, simple, and extensible distributed tracing library.

category: Web
homepage: https://github.com/mtth/tracing
license: BSD3
license-file: LICENSE
author: Matthieu Monsch
maintainer: [email protected]
copyright: 2020 Matthieu Monsch

build-type: Simple
extra-source-files:
README.md
extra-source-files: README.md

source-repository head
type: git
location: https://github.com/mtth/yx

library
hs-source-dirs:
src
hs-source-dirs: src
exposed-modules:
Control.Monad.Trace
, Control.Monad.Trace.Class
Expand All @@ -50,15 +48,13 @@ library
, time >= 1.8
, transformers >= 0.5
, unliftio >= 0.2
, unliftio-core < 0.2
ghc-options: -Wall
default-language: Haskell2010

test-suite tracing-test
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs:
test
hs-source-dirs: test
build-depends:
base
, containers
Expand Down

0 comments on commit 86aa9ea

Please sign in to comment.