mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-10-05 18:08:04 +03:00
remove Time
I want to remobe Polysemy and this was using that. There is no need to add time to log messages anyway, since we're using the systemd journal.
This commit is contained in:
parent
121ddb518c
commit
47815a5e87
@ -4,7 +4,7 @@ cabal-version: 2.2
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: def1de08738307f72bfcf97a872a2ff951f83ee880a9f6bcad482b8145b880fc
|
||||
-- hash: a211130dbcad57cde6ded74551b5390d00263e875e811750d2e3f168e96fcccf
|
||||
|
||||
name: nixpkgs-update
|
||||
version: 0.4.0
|
||||
@ -45,7 +45,6 @@ library
|
||||
Repology
|
||||
Rewrite
|
||||
Skiplist
|
||||
Time
|
||||
Update
|
||||
Utils
|
||||
Version
|
||||
|
55
src/Time.hs
55
src/Time.hs
@ -1,55 +0,0 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Time where
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Time.Clock (UTCTime, addUTCTime, getCurrentTime)
|
||||
import Data.Time.Format.ISO8601 (iso8601Show)
|
||||
import OurPrelude
|
||||
|
||||
data Time m a where
|
||||
Now :: Time m UTCTime
|
||||
|
||||
makeSem ''Time
|
||||
|
||||
runIO :: Member (Embed IO) r => Sem (Time ': r) a -> Sem r a
|
||||
runIO =
|
||||
interpret $ \case
|
||||
Now -> embed getCurrentTime
|
||||
|
||||
runPure :: UTCTime -> Sem (Time ': r) a -> Sem r a
|
||||
runPure t =
|
||||
interpret $ \case
|
||||
Now -> pure t
|
||||
|
||||
-- | Return the UTC time 1 hour ago
|
||||
|
||||
-- $setup
|
||||
-- >>> import Data.Time.Format (parseTimeOrError, defaultTimeLocale)
|
||||
-- >>> let exampleCurrentTime = parseTimeOrError False defaultTimeLocale "%Y-%-m-%-d" "2019-06-06" :: UTCTime
|
||||
--
|
||||
-- Examples:
|
||||
--
|
||||
-- >>> run $ runPure exampleCurrentTime oneHourAgo
|
||||
-- 2019-06-05 23:00:00 UTC
|
||||
|
||||
oneHourAgo :: Member Time r => Sem r UTCTime
|
||||
oneHourAgo = now <&> addUTCTime (fromInteger $ -60 * 60)
|
||||
|
||||
-- | Return the UTC time 2 hours ago
|
||||
--
|
||||
-- Examples:
|
||||
--
|
||||
-- >>> run $ runPure exampleCurrentTime twoHoursAgo
|
||||
-- 2019-06-05 22:00:00 UTC
|
||||
twoHoursAgo :: Member Time r => Sem r UTCTime
|
||||
twoHoursAgo = now <&> addUTCTime (fromInteger $ -60 * 60 * 2)
|
||||
|
||||
-- | Return the current ISO8601 date and time without timezone
|
||||
--
|
||||
-- Examples:
|
||||
--
|
||||
-- >>> run $ runPure exampleCurrentTime runDate
|
||||
-- "2019-06-06T00:00:00Z"
|
||||
runDate :: Member Time r => Sem r Text
|
||||
runDate = now <&> iso8601Show <&> T.pack
|
@ -42,7 +42,6 @@ import OurPrelude
|
||||
import qualified Outpaths
|
||||
import qualified Rewrite
|
||||
import qualified Skiplist
|
||||
import qualified Time
|
||||
import Utils
|
||||
( Boundary (..),
|
||||
Options (..),
|
||||
@ -73,9 +72,7 @@ alsoLogToAttrPath attrPath topLevelLog = do
|
||||
attrPathLog text
|
||||
|
||||
log' :: MonadIO m => FilePath -> Text -> m ()
|
||||
log' logFile msg = do
|
||||
runDate <- liftIO $ runM $ Time.runIO Time.runDate
|
||||
liftIO $ T.appendFile logFile (runDate <> " " <> msg <> "\n")
|
||||
log' logFile msg = liftIO $ T.appendFile logFile (msg <> "\n")
|
||||
|
||||
attrPathLogFilePath :: Text -> IO String
|
||||
attrPathLogFilePath attrPath = do
|
||||
|
@ -28,6 +28,5 @@ spec = do
|
||||
"-fspecialise-aggressively",
|
||||
"-fplugin=Polysemy.Plugin",
|
||||
"src/Version.hs",
|
||||
"src/GH.hs",
|
||||
"src/Time.hs"
|
||||
"src/GH.hs"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user