src/paths.bend
bolt@1.27.0.0 · 42 lines · 7 definitions
1
2
3
4
5import Base
6import bolt@1.27.0.0/src/lazy/lazy.bend as Lazy
7
8
9def base.go(segs: List<&2, String>, last: String) -> String:
10 match segs:
11 case Nil{}:
12 last
13 case Con{s, rest}:
14 base.go(rest, s)
15
16
17def base(path: String) -> String:
18 base.go(String.split(path, '/'), "")
19
20
21def tested(segs: List<&2, String>) -> Bool:
22 match segs:
23 case Nil{}:
24 False{}
25 case Con{+s, +rest}:
26 Lazy.or_else(Bool.and(String.eq(s, "tests"), Bool.not(List.is_empty(&2, String, rest))), _u => tested(rest))
27
28
29def is_test(path: String) -> Bool:
30 tested(String.split(path, '/'))
31
32
33def is_laws(path: String) -> Bool:
34 String.eq(base(path), "LAWS.bend")
35
36
37def is_proof(path: String) -> Bool:
38 String.eq(base(path), "PROOF.bend")
39
40
41def is_law_file(+path: String) -> Bool:
42 Bool.or(is_laws(path), is_proof(path))