@@ -38,6 +38,7 @@ data Status = Active | Inactive
3838
3939newtype MutableStatus = MutableStatus (IORef Status)
4040
41+-- | An action to activate a Fd cache entry.
4142type Refresh = IO ()
4243
4344status :: MutableStatus -> IO Status
@@ -65,6 +66,8 @@ newFdEntry path = FdEntry path
6566
6667type Hash = Int
6768type FdCache = MMap Hash FdEntry
69+
70+-- | Mutable Fd cacher.
6871newtype MutableFdCache = MutableFdCache (IORef FdCache)
6972
7073fdCache :: MutableFdCache -> IO FdCache
@@ -93,6 +96,8 @@ look mfc path key = searchWith key check <$> fdCache mfc
9396
9497----------------------------------------------------------------
9598
99+-- | Creating 'MutableFdCache' and executing the action in the second
100+-- argument. The first argument is a cache duration in second.
96101withFdCache :: Int -> (Maybe MutableFdCache -> IO a) -> IO a
97102withFdCache duration action = bracket (initialize duration)
98103 terminate
@@ -100,6 +105,7 @@ withFdCache duration action = bracket (initialize duration)
100105
101106----------------------------------------------------------------
102107
108+-- The first argument is a cache duration in second.
103109initialize :: Int -> IO (Maybe MutableFdCache)
104110initialize 0 = return Nothing
105111initialize duration = do
@@ -142,6 +148,7 @@ terminate (Just (MutableFdCache ref)) = mask_ $ do
142148
143149----------------------------------------------------------------
144150
151+-- | Getting 'Fd' and 'Refresh' from the mutable Fd cacher.
145152getFd :: MutableFdCache -> FilePath -> IO (Fd, Refresh)
146153getFd mfc path = look mfc path key >>= getFd'
147154 where