def walk

ezx@1.11.0.0 · src/ledger/ignore.bend:312

import ezx@1.11.0.0/src/ledger/ignore.bend as Ignore
import Base

312# every line, walked once. `fix` replaces a `.ez/` line. `blk` replaces the
313# first allowlist line, every later one is dropped, and `done` says the
314# block is already down; a file with no allowlist line gets it at the end.
315# Every other line is kept as it was.
316def walk(ls: List<&2, Line>, +fix: List<&2, String>, +blk: List<&2, String>, done: Bool) -> List<&2, String>:
317  match ls:
318    case []:
319      placed(done, blk)
320    case Line{k, +line} <> t:
321      match k:
322        case Other{}:
323          line <> walk(t, fix, blk, done)
324        case Dir{}:
325          List.append(&2, String, fix, walk(t, fix, blk, done))
326        case Star{}:
327          line <> walk(t, fix, blk, done)
328        case Lib{}:
329          line <> walk(t, fix, blk, done)
330        case Pkgs{}:
331          line <> walk(t, fix, blk, done)
332        case Allow{_h}:
333          List.append(&2, String, placed(done, blk), walk(t, fix, blk, True{}))

Uses (7)

Used by (1)