module OpenTracing.Time (AsMicros(micros)) where import Data.Int import Data.Time.Clock import Data.Time.Clock.POSIX import Data.Word class AsMicros a where micros :: Integral b => a -> b instance AsMicros UTCTime where micros :: forall b. Integral b => UTCTime -> b micros = forall a b. (RealFrac a, Integral b) => a -> b round forall b c a. (b -> c) -> (a -> b) -> a -> c . (POSIXTime 1000000forall a. Num a => a -> a -> a *) forall b c a. (b -> c) -> (a -> b) -> a -> c . UTCTime -> POSIXTime utcTimeToPOSIXSeconds {-# INLINE micros #-} instance AsMicros NominalDiffTime where micros :: forall b. Integral b => POSIXTime -> b micros = forall a b. (RealFrac a, Integral b) => a -> b round forall b c a. (b -> c) -> (a -> b) -> a -> c . (POSIXTime 1000000forall a. Num a => a -> a -> a *) {-# INLINE micros #-} {-# SPECIALIZE micros :: UTCTime -> Int64 #-} {-# SPECIALIZE micros :: UTCTime -> Word64 #-} {-# SPECIALIZE micros :: NominalDiffTime -> Int64 #-} {-# SPECIALIZE micros :: NominalDiffTime -> Word64 #-}