Stream: ideas

Topic: basic-cli Stdin.readToEnd


view this post on Zulip Luke Boswell (Nov 08 2024 at 01:19):

I'd like to add another effect to basic-cli similar to https://doc.rust-lang.org/std/io/trait.Read.html#method.read_to_end

Basically, read all the bytes into a List U8 until we see an EOF. This is useful for AoC.

Stdin.readToEnd : Task (List U8) [StdinErr _]

# purity inference
Stdin.readToEnd : {} => Result (List U8) [StdinErr _]
Stdin.readToEnd : Task (List U8) [StdinErr _]

view this post on Zulip jan kili (Nov 08 2024 at 13:42):

Are there other end conditions we'd want to support? I wonder if this could ergonomically support the Enter key, etc (eh maybe that duplicates Stdin.line)

view this post on Zulip jan kili (Nov 08 2024 at 13:45):

Maybe Stdin.readToEnd : [EOF, EOL, TAB, IDK] => Result (List U8) [StdinErr _]

view this post on Zulip jan kili (Nov 08 2024 at 13:47):

Or Stdin.readToEnd : [OfFile, OfLine, UntilTab, OfIdk] => Result (List U8) [StdinErr _]

view this post on Zulip jan kili (Nov 08 2024 at 13:52):

Semi related: Do we want a File.readLines function? It seems intentionally non-existent, but I don't think of it as a footgun vs needing to walk File.readLine or split File.readBytes/File.readUtf8 on newlines or pipe the file to this new Stdin function.

view this post on Zulip Brendan Hansknecht (Nov 08 2024 at 15:56):

Generally with stdin, you will only get granularity if 1 line at a time. So if you do something like UntilTab, it may feel very bugged. You press tab, but not get any data until an Eof, new line, or you type enough characters to force a buffer flush.

view this post on Zulip Brendan Hansknecht (Nov 08 2024 at 15:57):

So line and file are really the only two safe methods that won't confuse users


Last updated: Jun 16 2026 at 16:19 UTC