Console<RT>.readLine repeatedly returning same input without blocking
See original GitHub issueI modified the original example from https://github.com/louthy/language-ext/wiki/How-to-deal-with-side-effects#ioa which showcases the use of let:
var computation = from text in readAllText(inpath)
let ntext = Capitalise(text)
from _ in writeAllText(outpath, ntext)
select unit;
to
var computation = repeat(from l in Console<RT>.readLine
let r = l + l
from _ in Console<RT>.writeLine(r)
select unit);
Expected
The computation should work as REPL which echos the input twice.
What happens
When I enter some chars and press Enter, the console is scrolling forever and repeats printing the output without waiting for new user input.
However, the following works:
var computation = repeat(from l in Console<RT>.readLine
from r in SuccessEff(l + l)
from _ in Console<RT>.writeLine(r)
select unit);
Am I doing something wrong or is this a bug?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
capture keystroke without blocking [duplicate]
I usually use Console.ReadLine(); to capture a single keystroke. But this function blocks execution and keeps waiting for it to happen.
Read more >Simultaneously write to and read from the console (i.e. use ...
This means that you can basically use the WriteLine and ReadLine methods simultaneously without ReadLine blocking the console preventing you ...
Read more >C# Console.ReadLine Example
This reads input from the console. When the user presses enter, it returns a string. We can process this string like any other...
Read more >Console.ReadLine Method (System)
NewLine property. The returned string does not contain the terminating character(s). By default, the method reads input from a 256-character input buffer.
Read more >Repetition - C# Programming
ReadLine ()); // Read the input // if-else-if-else is one code block with multiple functions. // Check if number is too small. if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

FYI: I haven’t forgotten this, I’m just working on a more robust solution for the
AffandEffmonads to turn them into DSLs rather than use the Thunks, which are adding a bit too much complexity (and causing edge case issues like this, which in itself was caused by a fix to another issue).Thank you very much, I can confirm that both of my examples work as expected with version 4.1.0.