[seperate Ho dependencies out, in preperation for the ho cache and better batch compilation
John Meacham <john@repetae.net>**20090711023537
 Ignore-this: 99bb19123eb571a6fba40c16ecb52863
] hunk ./src/E/Lint.hs 54
-        putErrLn (show (e::SomeException))
+        putErrLn (show (e::SomeException'))
hunk ./src/Ho/Binary.hs 6
+import Data.Version
hunk ./src/Ho/Binary.hs 13
-instance Binary HoHeader where
-    put (HoHeader aa ab ac ad) = do
-	    put aa
-	    put ab
-	    put ac
-	    put ad
-    get = do
-        aa <- get
-        ab <- get
-        ac <- get
-        ad <- get
-        return (HoHeader aa ab ac ad)
hunk ./src/Ho/Binary.hs 45
+
+
+instance Data.Binary.Binary HoHeader where
+    put (HoHeader aa ab ac ad ae) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+	    Data.Binary.put ac
+	    Data.Binary.put ad
+	    Data.Binary.put ae
+    get = do
+    aa <- get
+    ab <- get
+    ac <- get
+    ad <- get
+    ae <- get
+    return (HoHeader aa ab ac ad ae)
+
+instance Data.Binary.Binary HoIDeps where
+    put (HoIDeps aa ab ac) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+	    Data.Binary.put ac
+    get = do
+    aa <- get
+    ab <- get
+    ac <- get
+    return (HoIDeps aa ab ac)
+
+instance Data.Binary.Binary HoLib where
+    put (HoLib aa ab ac) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+	    Data.Binary.put ac
+    get = do
+    aa <- get
+    ab <- get
+    ac <- get
+    return (HoLib aa ab ac)
+
+
+
+instance Binary Data.Version.Version where
+    put (Version a b) = put a >> put b 
+    get = liftM2 Version get get
+
hunk ./src/Ho/Build.hs 82
--- RDRT - redirect to another file for systems without symlinks
+-- LINK - redirect to another file for systems without symlinks
hunk ./src/Ho/Build.hs 88
---
+
+
+{-
+ - We separate the data into various chunks for logical layout as well as the important property that
+ - each chunk is individually compressed and accessable. What this means is
+ - that we can skip chunks we don't need. for instance, during the final link
+ - we have no need of the haskell type checking information, we are only
+ - interested in the compiled code, so we can jump directly to it. If we relied on straight
+ - serialization, we would have to parse all preceding information just to discard it right away.
+ - We also lay them out so that we can generate error messages quickly. for instance, we can determine
+ - if a symbol is undefined quickly, before it has to load the typechecking data.
+ -
+ -}
+
+-- | this should be updated every time the on-disk file format changes for a chunk. It is independent of the
+-- version number of the compiler.
+
+current_version :: Int
+current_version = 1
hunk ./src/Ho/Build.hs 109
-cff_rdrt  = chunkType "RDRT"
+cff_link  = chunkType "LINK"
hunk ./src/Ho/Build.hs 147
-    hosEncountered :: Map.Map HoHash     (FilePath,HoHeader,Ho),
+    hosEncountered :: Map.Map HoHash     (FilePath,HoHeader,HoIDeps,Ho),
hunk ./src/Ho/Build.hs 185
-            Just (fn,_,_a) -> return (True,fn)
+            Just (fn,_,_,a) -> return (True,fn)
hunk ./src/Ho/Build.hs 188
-                modifyIORef done_ref (hosEncountered_u $ Map.insert (hohHash hoh) (honame,hoh,ho))
+                modifyIORef done_ref (hosEncountered_u $ Map.insert (hohHash hoh) (honame,hoh,hidep,ho))
hunk ./src/Ho/Build.hs 250
-    = CompHo   (Maybe String)  HoHeader Ho
+    = CompHo   (Maybe String)  HoHeader HoIDeps Ho
hunk ./src/Ho/Build.hs 259
-instance ProvidesModules HoHeader where
-    providesModules hoh = fsts $ hohDepends hoh
+instance ProvidesModules HoIDeps where
+    providesModules hoh = fsts $ hoDepends hoh
+
hunk ./src/Ho/Build.hs 264
-    providesModules (CompHo _ hoh _)   = providesModules hoh
+    providesModules (CompHo _ _ hoh _)   = providesModules hoh
hunk ./src/Ho/Build.hs 277
-    f (CompHo (Just s) _ _) = s
-    f (CompHo _ _ _) = "ho"
+    f (CompHo (Just s) _ _ _) = s
+    f (CompHo _ _ _ _) = "ho"
hunk ./src/Ho/Build.hs 296
-        phomap = Map.fromListWith (++) (concat [  [ (m,[hh]) | (m,_) <- hohDepends hoh ] | (hh,(_,hoh,_)) <- Map.toList (hosEncountered done)])
+        phomap = Map.fromListWith (++) (concat [  [ (m,[hh]) | (m,_) <- hoDepends idep ] | (hh,(_,_,idep,_)) <- Map.toList (hosEncountered done)])
hunk ./src/Ho/Build.hs 332
-                Just (False,af@(fp,hoh,ho)) -> do
+                Just (False,af@(fp,hoh,idep,ho)) -> do
hunk ./src/Ho/Build.hs 334
-                    let stale = map (show . fst) (hohDepends hoh) `intersect` optStale options
-                    good <- catch ( mapM_ cdep (hohDepends hoh) >> mapM_ hvalid (hohModDepends hoh) >> return True) (\_ -> return False)
+                    let stale = map (show . fst) (hoDepends idep) `intersect` optStale options
+                    good <- catch ( mapM_ cdep (hoDepends idep) >> mapM_ hvalid (hoModDepends idep) >> return True) (\_ -> return False)
hunk ./src/Ho/Build.hs 341
-                        modifyIORef cug_ref ((h,(hohModDepends hoh,CompHo lib hoh ho)):)
+                        modifyIORef cug_ref ((h,(hoModDepends idep,CompHo lib hoh idep ho)):)
hunk ./src/Ho/Build.hs 377
-    forM_ (optHls options) $ \l -> do
-        (n',fn) <- findLibrary l
-        (hoh,_,ho) <- catch (readHoFile fn) $ \_ ->
-            fail $ "Error loading library file: " ++ fn
-        putVerboseLn $ printf "Library: %-15s <%s>" n' fn
-        modifyIORef done_ref (hosEncountered_u $ Map.insert (hohHash hoh) (n',hoh,ho))
-        modifyIORef done_ref (modEncountered_u $ Map.union (Map.fromList [ (m,ModLibrary n' (hohHash hoh)) | m <- providesModules hoh]))
+--    forM_ (optHls options) $ \l -> do
+--        (n',fn) <- findLibrary l
+--        (hoh,_,ho) <- catch (readHoFile fn) $ \_ ->
+--            fail $ "Error loading library file: " ++ fn
+--        putVerboseLn $ printf "Library: %-15s <%s>" n' fn
+--        modifyIORef done_ref (hosEncountered_u $ Map.insert (hohHash hoh) (n',hoh,ho))
+--        modifyIORef done_ref (modEncountered_u $ Map.union (Map.fromList [ (m,ModLibrary n' (hohHash hoh)) | m <- providesModules hoh]))
hunk ./src/Ho/Build.hs 422
-        CompHo _ hoh _    -> do ds <- mconcat `fmap` mapM countNodes deps
-                                return $ ds `Set.union` Set.fromList (map (show.fst) (hohDepends hoh))
+        CompHo _ hoh idep _  -> do ds <- mconcat `fmap` mapM countNodes deps
+                                   return $ ds `Set.union` Set.fromList (map (show.fst) (hoDepends idep))
hunk ./src/Ho/Build.hs 439
-        CompHo _ hoh ho -> do
+        CompHo _ hoh idep ho -> do
hunk ./src/Ho/Build.hs 441
-            forM_ (hohDepends hoh) $ \_ -> tickProgress cur
+            forM_ (hoDepends idep) $ \_ -> tickProgress cur
hunk ./src/Ho/Build.hs 455
+
hunk ./src/Ho/Build.hs 457
-                                 hohDepends    = [ (hsModuleName mod,h) | (h,mod) <- modules],
-                                 hohModDepends = hdep,
-                                 hohHash       = hh,
-                                 hohMetaInfo   = []
-                               }
-                idep = HoIDeps $ Map.fromList [ (h,(hsModuleName mod,hsModuleRequires mod)) | (h,mod) <- modules]
+                         hohVersion = current_version,
+                         hohName = Left mgName,
+                         hohHash       = hh,
+                         hohArchDeps = [],
+                         hohLibDeps   = []
+                         }
+                idep = HoIDeps {
+                        hoIDeps = Map.fromList [ (h,(hsModuleName mod,hsModuleRequires mod)) | (h,mod) <- modules],
+                        hoDepends    = [ (hsModuleName mod,h) | (h,mod) <- modules],
+                        hoModDepends = hdep
+                        }
+                (mgName:_) = sort $ map (hsModuleName . snd) modules
hunk ./src/Ho/Build.hs 471
-            writeIORef ref (CompCollected cho' (CompHo Nothing hoh newHo))
+            writeIORef ref (CompCollected cho' (CompHo Nothing hoh idep newHo))
hunk ./src/Ho/Build.hs 496
-    return (fc cff_jhdr,fc cff_idep,mempty { hoExp = fc cff_defs, hoBuild = fc cff_core})
+        hoh = fc cff_jhdr
+    when (hohVersion hoh /= current_version) $ fail "invalid version in hofile"
+    return (hoh,fc cff_idep,mempty { hoExp = fc cff_defs, hoBuild = fc cff_core})
hunk ./src/Ho/Build.hs 626
+buildLibrary ifunc func = undefined
+{-
hunk ./src/Ho/Build.hs 677
+-}
hunk ./src/Ho/Build.hs 697
-    when (not $ Map.null (hoIDeps idep)) $ putStrLn $ "IDeps:\n" <>  vindent (map pprint . Map.toList $ hoIDeps idep)
-    when (not $ Prelude.null (hohDepends hoh)) $ putStrLn $ "Dependencies:\n" <>  vindent (map pprint . sortUnder fst $ hohDepends hoh)
-    when (not $ Prelude.null (hohModDepends hoh)) $ putStrLn $ "ModDependencies:\n" <>  vindent (map pprint $ hohModDepends hoh)
-    when (not $ Prelude.null (hohMetaInfo hoh)) $ putStrLn $ "MetaInfo:\n" <> vindent (sort [text (' ':' ':k) <> char ':' <+> show v | (k,v) <- hohMetaInfo hoh])
+    let showList nm xs = when (not $ null xs) $ putStrLn $ (nm ++ ":\n") <>  vindent xs
+    showList "Dependencies" (map pprint . sortUnder fst $ hoDepends idep)
+    showList "ModDependencies" (map pprint $ hoModDepends idep)
+--    when (not $ Prelude.null (hohMetaInfo hoh)) $ putStrLn $ "MetaInfo:\n" <> vindent (sort [text (' ':' ':k) <> char ':' <+> show v | (k,v) <- hohMetaInfo hoh])
hunk ./src/Ho/Type.hs 23
+import Data.Version
hunk ./src/Ho/Type.hs 25
+
+-- A SourceHash is the hash of a specific file, it is associated with a
+-- specific 'Module' that said file implements.
hunk ./src/Ho/Type.hs 29
+-- HoHash is a unique identifier for a ho file or library.
hunk ./src/Ho/Type.hs 32
+
+-- while a 'Module' is a single Module associated with a single haskell source
+-- file, a 'ModuleGroup' identifies a group of mutually recursive modules.
+-- Generally it is chosen from among the Modules making up the group, but the
+-- specific choice has no other meaning. We could use the HoHash, but for readability
+-- reasons when debugging it makes more sense to choose an arbitrary Module.
+type ModuleGroup = Module
+
hunk ./src/Ho/Type.hs 41
+-- this is not stored in any file, but is what is collected from the ho files.
hunk ./src/Ho/Type.hs 43
-    -- this is a list of external names that are valid but that we may not know anything else about
-    -- it is used to recognize invalid ids.
-    choExternalNames :: IdSet,
-    choCombinators  :: IdMap Comb,
-    -- this is a map of ids to their full TVrs with all rules and whatnot attached.
+    -- this is a list of external names that are valid but that we may not know
+    -- anything else about it is used to recognize invalid ids.
+    choExternalNames :: IdSet, choCombinators  :: IdMap Comb,
+    -- this is a map of ids to their full TVrs with all rules and whatnot
+    -- attached.
hunk ./src/Ho/Type.hs 49
-    -- these are rules that may need to be retroactively applied to other modules
+    -- these are rules that may need to be retroactively applied to other
+    -- modules
hunk ./src/Ho/Type.hs 53
-    choHoMap :: Map.Map String Ho
-    }
+    choHoMap :: Map.Map String Ho }
hunk ./src/Ho/Type.hs 57
--- this is the immutable information about modules that depnends only on their contents
--- it can be trusted even if the ho file itself is out of date.
-newtype HoIDeps = HoIDeps {
-    hoIDeps :: Map.Map SourceHash (Module,[Module])
-    }
-    deriving(Binary)
+-- The header contains basic information about the file, it should be enough to determine whether
+-- we can discard the file right away or consider it further.
hunk ./src/Ho/Type.hs 61
+    -- * the version of the file format. it comes first so we don't try to read data that may be in a different format.
+    hohVersion  :: Int,
hunk ./src/Ho/Type.hs 64
-    hohHash       :: HoHash,
+    hohHash     :: HoHash,
+    -- * the human readable name, either the ModuleGroup or the library name and version.
+    hohName     :: Either ModuleGroup (PackedString,Version),
+    -- * library dependencies
+    hohLibDeps  :: [(PackedString,HoHash)],
+    -- * arch dependencies, these say whether the file is specialized for a
+    -- given arch.
+    hohArchDeps :: [(PackedString,PackedString)]
+    }
+
+-- These are the dependencies needed to check if a ho file is up to date.  it
+-- only appears in ho files as hl files do not have source code to check
+-- against or depend on anything but other libraries.
+data HoIDeps = HoIDeps {
+    -- * modules depended on indexed by a hash of the source.
+    hoIDeps :: Map.Map SourceHash (Module,[Module]),
hunk ./src/Ho/Type.hs 81
-    hohDepends    :: [(Module,SourceHash)],
+    hoDepends    :: [(Module,SourceHash)],
hunk ./src/Ho/Type.hs 83
-    hohModDepends :: [HoHash],
-    -- * metainformation, filled for hl-files, empty for normal objects.
-    hohMetaInfo   :: [(String,PackedString)]
+    hoModDepends :: [HoHash] }
+
+data HoLib = HoLib {
+    -- * arbitrary metainformation such as library author, web site, etc.
+    hoMetaInfo   :: [(String,PackedString)],
+    hoModuleMap  :: Map.Map Module ModuleGroup,
+    hoHiddenModules :: [Module]
hunk ./src/Ho/Type.hs 98
+-- classes are used by both the core transformations and front end typechecking
+-- so they are in their own section
+
+newtype HoClass = HoClass {
+    hoClasses :: Map.Map Module ClassHierarchy
+    } deriving(Binary)
hunk ./src/Interactive.hs 141
-        rx <- CE.catch ( Just `fmap` evaluate (mkRegex reg)) (\(e::SomeException) -> return Nothing)
+        rx <- CE.catch ( Just `fmap` evaluate (mkRegex reg)) (\(e::SomeException') -> return Nothing)
hunk ./src/Interactive.hs 156
-            CE.catch (runIn isStart { stateInteract = act } $ executeStatement e) $ (\e -> putStrLn $ show (e::SomeException))
+            CE.catch (runIn isStart { stateInteract = act } $ executeStatement e) $ (\e -> putStrLn $ show (e::SomeException'))