forked from GitHub/gf-core
gf-server: the readData function given to getData should be m a, not IO a.
This commit is contained in:
@@ -109,15 +109,15 @@ type DataRef a = IORef (Maybe (ClockTime, a))
|
|||||||
newDataRef :: MonadIO m => m (DataRef a)
|
newDataRef :: MonadIO m => m (DataRef a)
|
||||||
newDataRef = liftIO $ newIORef Nothing
|
newDataRef = liftIO $ newIORef Nothing
|
||||||
|
|
||||||
getData :: MonadIO m => (FilePath -> IO a) -> DataRef a -> FilePath -> m a
|
getData :: MonadIO m => (FilePath -> m a) -> DataRef a -> FilePath -> m a
|
||||||
getData loadData ref file = liftIO $
|
getData loadData ref file =
|
||||||
do t' <- getModificationTime file
|
do t' <- liftIO $ getModificationTime file
|
||||||
m <- readIORef ref
|
m <- liftIO $ readIORef ref
|
||||||
case m of
|
case m of
|
||||||
Just (t,x) | t' == t -> return x
|
Just (t,x) | t' == t -> return x
|
||||||
_ -> do logCGI $ "Loading " ++ show file ++ "..."
|
_ -> do logCGI $ "Loading " ++ show file ++ "..."
|
||||||
x <- loadData file
|
x <- loadData file
|
||||||
writeIORef ref (Just (t',x))
|
liftIO $ writeIORef ref (Just (t',x))
|
||||||
return x
|
return x
|
||||||
|
|
||||||
-- Logging
|
-- Logging
|
||||||
|
|||||||
Reference in New Issue
Block a user