Chapter 4

Files and Paths

Walk directories, read text, and write results safely.

The filesystem is first-class

example.hhy
path("./logs")
    |> files("**/*.log")
    |> where { file -> file.size > 1mib }
    |> flat_map { file -> read_lines(file.path) }
    |> where { line -> contains(line, "ERROR") }
    |> save_lines(path("errors.txt"))

files returns a lazy File Stream. Paths are lexically normalized; recursive walking can opt into symlinks with cycle protection. save_text and save_lines use atomic replacement semantics.

Core capabilities

  • read_text / read_lines
  • write_text / append_text / save_text / save_lines
  • files / copy / move / remove
  • path_join / path_name / path_extension / path_parent