@@ -32,9 +32,17 @@ data ModuleTree = MTree { mod_path :: IFileType,
3232 mod_deps :: [ModuleTree] }
3333 deriving Show
3434
35−latest :: UTCTime -> [ModuleTree] -> UTCTime
36−latest tm [] = tm
37−latest tm (m : ms) = latest (max tm (mod_time m)) (ms ++ mod_deps m)
35+latest :: UTCTime -> [IFileType] -> [ModuleTree] -> UTCTime
36+latest tm done [] = tm
37+latest tm done (m : ms)
38+ | mod_path m `elem` done = latest tm done ms
39+ | otherwise = latest (max tm (mod_time m)) (mod_path m : done)
40+ (ms ++ mod_deps m)
41+
42+modName :: IFileType -> String
43+modName (IDR fp) = fp
44+modName (LIDR fp) = fp
45+modName (IBC fp src) = modName src
3846
3947-- | Given a module tree, return the list of files to be loaded. If
4048-- any module has a descendent which needs reloading, return its
@@ -46,17 +54,17 @@ getModuleFiles ts = nub $ execState (modList ts) [] where
4654 modList (m : ms) = do modTree [] m; modList ms
4755
4856 modTree path (MTree p rechk tm deps)
49− = do let file = chkReload rechk p
50− -- Needs rechecking if 'rechk' is true, or if any of the
51− -- modification times in 'deps' are later than tm
52− let depMod = latest tm deps
53− let needsRechk = rechk || depMod > tm
54−
55− st <- get
56− if needsRechk then put $ nub (getSrc file : updateToSrc path st)
57− else put $ nub (file : st)
58−-- when (not (ibc p) || rechk) $
59− mapM_ (modTree (getSrc p : path)) deps
57+ = do let file = chkReload rechk p
58+ -- Needs rechecking if 'rechk' is true, or if any of the
59+ -- modification times in 'deps' are later than tm
60+ let depMod = latest tm [] deps
61+ let needsRechk = rechk || depMod > tm
62+
63+ st <- get
64+ if needsRechk then put $ nub (getSrc file : updateToSrc path st)
65+ else put $ nub (file : st)
66+ st <- get
67+ mapM_ (modTree (getSrc p : path)) deps
6068
6169 chkReload False p = p
6270 chkReload True (IBC fn src) = chkReload True src