Skip to content

Commit

Permalink
Added Knit.Report.Cache.cachedNow
Browse files Browse the repository at this point in the history
  • Loading branch information
adamConnerSax committed Oct 16, 2024
1 parent 7691fda commit 41975e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Knit/Report/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module Knit.Report.Cache
, updateIf
, loadOrMakeFile
, oldestUnit
, cachedNow
-- * Re-Exports
, UTCTime
)
Expand Down Expand Up @@ -325,3 +326,9 @@ oldestUnit cts = withCacheTime t (pure ()) where
-- t = minimum $ fmap C.cacheTime cts
t = join $ Foldl.fold Foldl.minimum $ fmap C.cacheTime cts
{-# INLINEABLE oldestUnit #-}

-- | Utility to lift something into a time-stamped thing with the time as now
cachedNow :: P.Member (P.Embed IO) r => P.Sem r a -> P.Sem r (ActionWithCacheTime r a)
cachedNow ma = do
nowCT <- P.embed Time.getCurrentTime
pure $ C.withCacheTime (Just nowCT) ma

0 comments on commit 41975e7

Please sign in to comment.