PhysLean/HepLean/Meta/AllFilePaths.lean
KUO-TSAN HSU (Gordon) f8f94979ab
feat: make informal_definition and informal_lemma commands (#300)
* make informal_definition and informal_lemma commands
* drop the fields "math", "physics", and "proof" from InformalDefinition/InformalLemma and use docstrings instead
* render informal docstring in dependency graph
2025-02-02 03:17:17 +08:00

30 lines
899 B
Text

/-
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.TODO.Basic
/-!
## Getting an array of all file paths in HepLean.
-/
open System
TODO "Make this definition more functional in style. In other words, remove the for loop."
/-- The recursive function underlying `allFilePaths`. -/
partial def allFilePaths.go (prev : Array FilePath)
(root : String) (path : FilePath) : IO (Array FilePath) := do
let mut r := prev
for entry in ← path.readDir do
if ← entry.path.isDir then
r ← go r (root ++ "/" ++ entry.fileName) entry.path
else
r := r.push (root ++ "/" ++ entry.fileName)
pure r
/-- Gets an array of all file paths in `HepLean`. -/
partial def allFilePaths : IO (Array FilePath) := do
allFilePaths.go (#[] : Array FilePath) "./HepLean" ("./HepLean" : FilePath)