[clean up progress updates some more, start making room for libraries again
John Meacham <john@repetae.net>**20090808022311
 Ignore-this: 5656c256d1f6c1f1f71c157934bf6cb9
] hunk ./configure.ac 1
-AC_INIT([jhc],[0.6.1])
+AC_INIT([jhc],[0.6.2])
hunk ./configure.ac 7
-REVISION=20090622
+REVISION=20090806
hunk ./src/Ho/Binary.hs 55
+{-
hunk ./src/Ho/Binary.hs 66
+    -}
hunk ./src/Ho/Build.hs 255
-    | CompTCedSource HoTcInfo TiData [(HoHash,HsModule)] [String]
+    | CompLib ModuleGroup
hunk ./src/Ho/Build.hs 378
+    putProgressLn "Finding Dependencies..."
hunk ./src/Ho/Build.hs 381
+    putProgressLn "Typechecking..."
hunk ./src/Ho/Build.hs 383
+    putProgressLn "Compiling..."
hunk ./src/Ho/Build.hs 458
---    let showProgress ms = forM_ ms $ \modName ->
---          do curModule <- tickProgress
---             printf "[%*d of %*d] %s\n" fmtLen curModule fmtLen maxModules (show $ hsModuleName modName)
---        showProgress ms = forM_ ms $ \modName ->
---          do curModule <- tickProgress
---             printf "[%*d of %*d] %s\n" fmtLen curModule fmtLen maxModules (show $ hsModuleName modName)
---             printf fmtStr curModule maxModules (show $ hsModuleName modName)
-        --fmtStr = printf "[%%%id of %*d] %%s]" fmtLen fmtLen maxModules where
hunk ./src/Ho/Build.hs 484
-                --writeIORef ref (CompTCed ctc' (Just (htc,tidata,modules,map sourceHoName sc)) cn)
-                writeIORef ref (CompTCed ctc' (Just (htc,tidata,modules,map sourceHoName sc)) CompPhony)
+                writeIORef ref (CompTCed ctc' (Just (htc,tidata,modules,map sourceHoName sc)) cn)
hunk ./src/Ho/Build.hs 493
-compileCompNode ifunc func ksm cn = do ns <- countNodes cn
-                                       cur <- newMVar (1::Int)
-                                       ksm_r <- newIORef ksm
-                                       f (Set.size ns) cur ksm_r cn where
-    countNodes (CompNode hh deps ref) = readIORef ref >>= g where
-        g cn =  case cn of
-            CompTCed _ _ cn   -> g cn
-            CompCollected _ _ -> return Set.empty
-            CompPhony         -> mconcat `fmap` mapM countNodes deps
-            CompHo _ hoh idep _  -> do ds <- mconcat `fmap` mapM countNodes deps
-                                       return $ ds `Set.union` Set.fromList (map (show.fst) (hoDepends idep))
-            CompSources sc    -> do ds <- mconcat `fmap` mapM countNodes deps
-                                    return $ ds `Set.union` Set.fromList (map sourceIdent sc)
-    tickProgress cur
-        = modifyMVar cur $ \val -> return (val+1,val)
-    showProgress maxModules cur ms
-        = forM_ ms $ \modName ->
-          do curModule <- tickProgress cur
-             let l = ceiling (logBase 10 (fromIntegral maxModules+1) :: Double) :: Int
-             printf "[%*d of %*d] %s\n" l curModule l maxModules (show $ hsModuleName modName)
-    f n cur ksm_r (CompNode hh deps ref) = readIORef ref >>= g where
-        g cn = case cn of
-            CompCollected ch _ -> return ch
-            CompPhony -> do
-                xs <- mconcat `fmap` mapM (f n cur ksm_r) deps
-                writeIORef ref (CompCollected xs CompPhony)
-                return xs
-            CompHo _ hoh idep ho -> do
-                cho <- mconcat `fmap` mapM (f n cur ksm_r) deps
-                forM_ (hoDepends idep) $ \_ -> tickProgress cur
-                cho <- ifunc cho ho
-                writeIORef ref (CompCollected cho cn)
-                return cho
-            CompTCed _ Nothing nn -> g nn
-            CompTCed _ (Just (htc,tidata,modules,shns)) _  -> do
-                let hdep = [ h | CompNode h _ _ <- deps]
-                cho <- mconcat `fmap` mapM (f n cur ksm_r) deps
-                --showProgress n cur (snds modules)
-                --(cho',newHo) <- func cho (snds modules)
-                let (mgName:_) = sort $ map (hsModuleName . snd) modules
-                (cho',newHo) <- func cho mempty { hoModuleGroup = mgName, hoTcInfo = htc } tidata
-                modifyIORef ksm_r (Map.union $ Map.fromList [ (h,(hsModuleName mod,hsModuleRequires mod)) | (h,mod) <- modules])
-                ksm <- readIORef ksm_r
-
-                let hoh = HoHeader {
-                             hohVersion = current_version,
-                             hohName = Left mgName,
-                             hohHash       = hh,
-                             hohArchDeps = [],
-                             hohLibDeps   = []
-                             }
-                    idep = HoIDeps {
-                            hoIDeps =    ksm,
-                            hoDepends    = [ (hsModuleName mod,h) | (h,mod) <- modules],
-                            hoModDepends = hdep
-                            }
-
-                recordHoFile newHo idep shns hoh
-                writeIORef ref (CompCollected cho' (CompHo Nothing hoh idep newHo))
-                return cho'
-            CompSources _ -> error "sources still exist!?"
+compileCompNode ifunc func ksm cn = do
+    cur <- newMVar (1::Int)
+    ksm_r <- newIORef ksm
+    let countNodes (CompNode hh deps ref) = readIORef ref >>= g where
+            g cn =  case cn of
+                CompTCed _ _ cn   -> g cn
+                CompCollected _ _ -> return Set.empty
+                CompPhony         -> mconcat `fmap` mapM countNodes deps
+                CompHo _ hoh idep _  -> do ds <- mconcat `fmap` mapM countNodes deps
+                                           return $ ds `Set.union` Set.fromList (map (show.fst) (hoDepends idep))
+                CompSources sc    -> do ds <- mconcat `fmap` mapM countNodes deps
+                                        return $ ds `Set.union` Set.fromList (map sourceIdent sc)
+        tickProgress = modifyMVar cur $ \val -> return (val+1,val)
+    maxModules <- Set.size `fmap` countNodes cn
+    let showProgress ms = printModProgress fmtLen maxModules tickProgress ms
+        fmtLen = ceiling (logBase 10 (fromIntegral maxModules+1) :: Double) :: Int
+    let f (CompNode hh deps ref) = readIORef ref >>= g where
+            g cn = case cn of
+                CompCollected ch _ -> return ch
+                CompPhony -> do
+                    xs <- mconcat `fmap` mapM f deps
+                    writeIORef ref (CompCollected xs CompPhony)
+                    return xs
+                CompHo _ hoh idep ho -> do
+                    cho <- mconcat `fmap` mapM f deps
+                    forM_ (hoDepends idep) $ \_ -> tickProgress
+                    cho <- ifunc cho ho
+                    writeIORef ref (CompCollected cho cn)
+                    return cho
+                CompTCed _ Nothing nn -> g nn
+                CompTCed _ (Just (htc,tidata,modules,shns)) _  -> do
+                    let hdep = [ h | CompNode h _ _ <- deps]
+                    cho <- mconcat `fmap` mapM f deps
+                    showProgress (snds modules)
+                    let (mgName:_) = sort $ map (hsModuleName . snd) modules
+                    (cho',newHo) <- func cho mempty { hoModuleGroup = mgName, hoTcInfo = htc } tidata
+                    modifyIORef ksm_r (Map.union $ Map.fromList [ (h,(hsModuleName mod,hsModuleRequires mod)) | (h,mod) <- modules])
+                    ksm <- readIORef ksm_r
hunk ./src/Ho/Build.hs 532
+                    let hoh = HoHeader {
+                                 hohVersion = current_version,
+                                 hohName = Left mgName,
+                                 hohHash       = hh,
+                                 hohArchDeps = [],
+                                 hohLibDeps   = []
+                                 }
+                        idep = HoIDeps {
+                                hoIDeps =    ksm,
+                                hoDepends    = [ (hsModuleName mod,h) | (h,mod) <- modules],
+                                hoModDepends = hdep
+                                }
hunk ./src/Ho/Build.hs 545
+                    recordHoFile newHo idep shns hoh
+                    writeIORef ref (CompCollected cho' (CompHo Nothing hoh idep newHo))
+                    return cho'
+                CompSources _ -> error "sources still exist!?"
+    f cn
+--    showProgress maxModules cur ms
+--        = forM_ ms $ \modName ->
+--          do curModule <- tickProgress cur
+--             let l = ceiling (logBase 10 (fromIntegral maxModules+1) :: Double) :: Int
+--             printf "[%*d of %*d] %s\n" l curModule l maxModules (show $ hsModuleName modName)
hunk ./src/Ho/Build.hs 556
--- Read in a Ho file.
hunk ./src/Ho/Build.hs 557
-readHoFile :: FilePath -> IO (HoHeader,HoIDeps,Ho)
-readHoFile fn = do
+readHFile :: FilePath -> IO (FilePath,HoHeader,forall a . Binary a => ChunkType -> a)
+readHFile fn = do
hunk ./src/Ho/Build.hs 567
-        hoh = fc cff_jhdr
-        Left modGroup = hohName hoh
+    let hoh = fc cff_jhdr
hunk ./src/Ho/Build.hs 569
+    return (fn',hoh,fc)
+
+-- Read in a Ho file.
+
+readHoFile :: FilePath -> IO (HoHeader,HoIDeps,Ho)
+readHoFile fn = do
+    (_fn',hoh,fc) <- readHFile fn
+    let Left modGroup = hohName hoh
hunk ./src/Ho/Build.hs 702
+--collectLibraries :: IO [FilePath]
+--collectLibraries = concat `fmap` mapM f (optHlPath options) where
+--    f fp = do
+--        fs <- flip catch (\_ -> return []) $ getDirectoryContents fp
+--        flip mapM fs $ \e -> case reverse e of
+--            ('l':'h':'.':r)  -> do
+--                (fn',hoh,mp) <- readHFile (fp++"/"++e)
+--
+--        _               -> []
+
hunk ./src/Ho/Library.hs 12
+import Data.List
hunk ./src/Ho/Library.hs 64
-
hunk ./src/Ho/Library.hs 73
+{-
+collectLibraries :: IO [FilePath]
+collectLibraries ms = concat `fmap` mapM f (optHlPath options) where
+    f fp = flip catch (\_ -> return []) $ do
+        fs <- getDirectoryContents fp
+        return $ flip concatMap fs $ \e ->
+            case reverse e of
+              ('l':'h':'.':r) | good e -> [(fp++"/"++e)]
+              _               -> []
+    good e = case ms of
+        Nothing -> True
+        Just rs -> any (`isPrefixOf` e) rs
+
+collectPotentialLibraries :: Maybe [String] -> IO [FilePath]
+collectPotentialLibraries ms = concat `fmap` mapM f (optHlPath options) where
+    f fp = flip catch (\_ -> return []) $ do
+        fs <- getDirectoryContents fp
+        return $ flip concatMap fs $ \e ->
+            case reverse e of
+              ('l':'h':'.':r) | good e -> [(fp++"/"++e)]
+              _               -> []
+    good e = case ms of
+        Nothing -> True
+        Just rs -> any (`isPrefixOf` e) rs
+
+    -}
+
+
hunk ./src/Ho/Type.hs 90
---    hoModuleDeps :: Map.Map ModuleGroup [ModuleGroup],
-    hoHiddenModules :: [Module]
+    hoModuleDeps :: Map.Map ModuleGroup [ModuleGroup],
+    hoHiddenModules :: [Module],
+    -- for libraries we have to keep these seperated
+    -- by module group since they are inherited whenever
+    -- the corresponding modules are imported
+    hoClasses :: Map.Map ModuleGroup ClassHierarchy,
+    hoLibRules :: Map.Map ModuleGroup Rules
hunk ./src/Ho/Type.hs 99
-data CollectedTc = CollectedTc {
-    ctcClassHierarchy :: ClassHierarchy,
-    ctcInfo :: HoTcInfo
-    }
-    {-! derive: update, Monoid !-}
hunk ./src/Ho/Type.hs 113
--- classes and the datatable are used by both the core transformations and
--- front end typechecking so they are in their own section
-
--- this needs datatable
-newtype HoClass = HoClass {
-    hoClasses :: Map.Map Module ClassHierarchy
-    } deriving(Binary,Monoid)
hunk ./src/Main.hs 326
-    putProgressLn "Initial optimization pass"
+    --putProgressLn "Initial optimization pass"
hunk ./src/Main.hs 332
-    wdump FD.Progress $
+    wdump FD.Stats $
hunk ./src/Main.hs 346
-    wdump FD.Progress $
+    wdump FD.Stats $
hunk ./src/Main.hs 394
-    wdump FD.Progress $
+    wdump FD.Stats $
hunk ./src/Main.hs 411
---        (mod:_) = Map.keys $ hoExports $ hoTcInfo ho'
hunk ./src/Main.hs 447
-    putProgressLn "Starting Collected Compilation"
+    putProgressLn "Collected Compilation..."