// Standard input line by line (ADR 0086), from stdin_lines.stdin: a CRLF // line loses its "\r" too, a lone "\r" stays, an empty line is a line, and // a last line without newline is still one. Input then ends, for every // later read. import std/io fn shown :: r: Result, io.Error> -> String { match r { Ok(Some(line)) -> "line " <> debug line , Ok(None) -> "end" , Error(e) -> "error " <> show e } } fn lines :: -> () / { let r = io.read_line () io.println (shown r) match r { Ok(Some(_)) -> lines (), _ -> () } } pub fn main :: -> () / { lines () io.println ("again: " <> shown (io.read_line ())) match io.read_bytes 10 { Ok(None) -> io.println "bytes: end", _ -> io.println "bytes: more?" } } //> line "first" //> line "second, CRLF" //> line "" //> line " spaced " //> line "a\rb" //> line "été" //> line "last, no newline" //> end //> again: end //> bytes: end