1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#[macro_use]
use corollary_support::*;
pub type InputStream = ByteString;
pub fn takeByte(bs: InputStream) -> (Word8, InputStream) {
seq(BSW::head(bs.clone()), (BSW::head(bs.clone()), BSW::tail(bs)))
}
pub fn takeChar(bs: InputStream) -> (char, InputStream) {
seq(BSC::head(bs.clone()), (BSC::head(bs.clone()), BSC::tail(bs)))
}
pub fn inputStreamEmpty(bs: InputStream) -> bool {
BSW::null(bs)
}
pub fn takeChars(n: isize, bstr: InputStream) -> Vec<char> {
BSC::unpack(BSC::take(n, bstr)).chars().collect()
}
pub fn takeChars_str(n: isize, bstr: InputStream) -> String {
BSC::unpack(BSC::take(n, bstr)).chars().collect()
}
pub fn readInputStream(f: FilePath) -> InputStream {
BSW::readFile(f)
}
pub fn inputStreamToString(bs: InputStream) -> String {
BSC::unpack(bs)
}
pub fn inputStreamFromString(s: String) -> InputStream {
BSC::pack(s)
}
pub fn countLines(bs: InputStream) -> isize {
length(BSC::lines(bs))
}