-- |
-- Module      : Network.Pusher.Internal.Util
-- Description : Various utility functions
-- Copyright   : (c) Will Sewell, 2016
-- Licence     : MIT
-- Maintainer  : me@willsewell.com
-- Stability   : stable
module Network.Pusher.Internal.Util
  ( show',
    getSystemTimeSeconds,
  )
where

import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.String (IsString, fromString)
import Data.Time.Clock.System (SystemTime (systemSeconds), getSystemTime)
import Data.Word (Word64)

-- | Generalised version of show.
show' :: (Show a, IsString b) => a -> b
show' :: forall a b. (Show a, IsString b) => a -> b
show' = forall a. IsString a => String -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show

getSystemTimeSeconds :: MonadIO m => m Word64
getSystemTimeSeconds :: forall (m :: * -> *). MonadIO m => m Word64
getSystemTimeSeconds = do
  SystemTime
t <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO SystemTime
getSystemTime
  forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ SystemTime -> Int64
systemSeconds SystemTime
t