How would I read from Stdin until EOT? I'm trying to pipe input into a basic-cli app and it crashes.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:298:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
This is my best attempt:
loop : Str -> Task [Step Str, Done Str] never
loop = \a -> Task.attempt Stdin.line \x -> when x is
Ok b -> Task.succeed (Step (Str.concat a b))
Err _ -> Task.succeed (Done a)
stdin <- await (Task.loop "" loop)
I think this is a case where we need to change how the stdin function works on the platform
I think we currently have it just unwrap the stdin option when it really should return an option in the function
That way you know when you hit eof instead of crashing
Basically, we have a bad default currently that crashes on any error and eof is being considered an error.
This would probably be a good first issue for anyone interested.
Should we change the type of Stdin.line to Task [Input Str, End] *
?
Should we change the type of Stdin.line to
Task [Input Str, End] *
?
I like the sound of that
Should Eof be a normal state or an error state? I would assume it is a error that you normally match on/react to, but I guess either is valid
Hmm...in rust, I guess it is result option str
So eof is part of the positive side, not error side
Yeah I don't think it makes sense for eof to be considered an error
I have this implemented, just need to make sure everything is right and then I'll open up a PR another day
Last updated: Jul 06 2025 at 12:14 UTC