main.bend
ezsys@0.1.0.0 · 140 lines · 25 definitions
1
2
3
4
5
6
7
8import Base
9import ezsys@0.1.0.0/src/sys.bend as Sys
10import ezsys@0.1.0.0/src/clock.bend as Clock
11import ezsys@0.1.0.0/src/text.bend as Text
12import ezsys@0.1.0.0/src/errno.bend as Err
13import ezsys@0.1.0.0/src/str.bend as Str
14
15
16def file.read(path: String) -> IO(Result<&1, &1, U32 & String, String>):
17 Sys.sys.read(path)
18
19
20def file.write(
21 path: String,
22 text: String
23) -> IO(Result<&1, &1, U32 & String, Unit>):
24 Sys.sys.write(path, text)
25
26
27
28def file.save(
29 path: String,
30 text: String
31) -> IO(Result<&1, &1, U32 & String, Unit>):
32 Sys.sys.save(path, text)
33
34
35
36def env.or(name: String, fallback: String) -> IO(String):
37 Sys.sys.env(name, fallback)
38
39
40
41def time.now() -> IO(U32 & U32):
42 Sys.ezsys.clock()
43
44
45
46def time.iso(secs: U32, ms: U32) -> String:
47 Clock.time.iso(secs, ms)
48
49
50
51def time.civil(secs: U32) -> U32 & U32 & U32 & U32 & U32 & U32 & U32:
52 Clock.time.fields(secs)
53
54
55def time.iso_week(secs: U32) -> U32 & U32:
56 Clock.time.iso_week(secs)
57
58
59def time.iso_week_text(secs: U32) -> String:
60 Clock.time.iso_week_text(secs)
61
62
63def time.now_iso() -> IO(String):
64 Sys.sys.now_iso()
65
66
67
68def text.fill(template: String, pairs: List<(String & String)>) -> String:
69 Text.text.fill(template, Text.text.own(pairs))
70
71
72def text.fill_with(
73 open: String,
74 close: String,
75 template: String,
76 pairs: List<(String & String)>
77) -> String:
78 Text.text.fill_with(open, close, template, Text.text.own(pairs))
79
80
81
82def text.strip(txt: String) -> String:
83 Str.text.strip(txt)
84
85
86def text.lstrip(txt: String) -> String:
87 Str.text.lstrip(txt)
88
89
90def text.rstrip(txt: String) -> String:
91 Str.text.rstrip(txt)
92
93
94
95def text.replace(txt: String, old: String, new: String) -> String:
96 Str.text.replace(txt, old, new)
97
98
99
100def text.split(txt: String, sep: String) -> List<&2, String>:
101 Str.text.split(txt, sep)
102
103
104
105def text.find(txt: String, needle: String) -> Maybe<&2, U32>:
106 Str.text.find(txt, needle)
107
108
109
110def text.lower(txt: String) -> String:
111 Str.text.lower(txt)
112
113
114
115def text.upper(txt: String) -> String:
116 Str.text.upper(txt)
117
118
119def text.pad_right(txt: String, width: Nat) -> String:
120 Str.text.pad_right(txt, width)
121
122
123def text.truncate(txt: String, width: Nat) -> String:
124 Str.text.truncate(txt, width)
125
126
127def digits.cmp(lhs: String, rhs: String) -> Cmp:
128 Str.text.digits.cmp(lhs, rhs)
129
130
131
132def dir.list(
133 path: String
134) -> IO(Result<&1, &1, U32 & String, List<&2, String>>):
135 Sys.sys.list(path)
136
137
138
139def err.os(code: U32, why: String, path: String) -> String:
140 Err.err.os(code, why, path)