File: Cache/Hashing.lean

full_name: Cache.Hashing.HashMemo.rootHash
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: UInt64

full_name: Cache.Hashing.instInhabitedHashMemo
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: Inhabited Cache.Hashing.HashMemo

full_name: Cache.Hashing.HashMemo.depsMap
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: Lean.HashMap System.FilePath (Array System.FilePath)

full_name: Cache.Hashing.HashMemo.cache
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: Lean.HashMap System.FilePath (Option UInt64)

full_name: Cache.Hashing.HashMemo.hashMap
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: Cache.IO.HashMap

full_name: Cache.Hashing.HashMemo
code: structure HashMemo where
  rootHash : UInt64
  depsMap  : Lean.HashMap FilePath (Array FilePath) := {}
  cache    : Lean.HashMap FilePath (Option UInt64) := {}
  hashMap  : HashMap := {}
  deriving Inhabited
goal: Type

full_name: Cache.Hashing.insertDeps
code: partial def insertDeps (hashMap : HashMap) (path : FilePath) (hashMemo : HashMemo) : HashMap 
goal: Cache.IO.HashMap

full_name: Cache.Hashing.HashMemo.filterByFilePaths
code: /--
Filters the `HashMap` of a `HashMemo` so that it only contains key/value pairs such that every key:
* Belongs to the given list of file paths or
* Corresponds to a file that's imported (transitively of not) by some file in the list of file paths
-/
def HashMemo.filterByFilePaths (hashMemo : HashMemo) (filePaths : List FilePath) : IO HashMap 
goal: IO Cache.IO.HashMap

full_name: Cache.Hashing.HashM
code: /-- We cache the hash of each file and their dependencies for later lookup -/
abbrev HashM 
goal: Type

full_name: Cache.Hashing.getFileImports
code: /-- Gets the file paths to Mathlib files imported on a Lean source -/
def getFileImports (source : String) (pkgDirs : PackageDirs) : Array FilePath 
goal: Array System.FilePath

full_name: Cache.Hashing.hashFileContents
code: /-- Computes a canonical hash of a file's contents. -/
def hashFileContents (contents : String) : UInt64 
goal: UInt64

full_name: Cache.Hashing.getRootHash
code: /--
Computes the root hash, which mixes the hashes of the content of:
* `lakefile.lean`
* `lean-toolchain`
* `lake-manifest.json`
and the hash of `Lean.versionString`.

(We hash `Lean.versionString` in case the toolchain changes even though `lean-toolchain` hasn't.
This happens with the `lean-pr-testing-NNNN` toolchains when Lean 4 PRs are updated.)
-/
def getRootHash : CacheM UInt64 
goal: Cache.IO.CacheM UInt64

full_name: Cache.Hashing.getFileHash
code: /--
Computes the hash of a file, which mixes:
* The root hash
* The hash of its relative path (inside its package directory)
* The hash of its content
* The hashes of the imported files that are part of `Mathlib`
-/
partial def getFileHash (filePath : FilePath) : HashM <| Option UInt64 
goal: Cache.Hashing.HashM (Option UInt64)

full_name: Cache.Hashing.roots
code: /-- Files to start hashing from. -/
def roots : Array FilePath 
goal: Array System.FilePath

full_name: Cache.Hashing.getHashMemo
code: /-- Main API to retrieve the hashes of the Lean files -/
def getHashMemo (extraRoots : Array FilePath) : CacheM HashMemo 
goal: Cache.IO.CacheM Cache.Hashing.HashMemo