Console Module
The Console module exposes basic text I/O through host-provided runtime externs.
Console.writeLine : string -> unit
Writes one line of text to standard output.
Console.writeLine "hello"
Console.writeLine $"args={Env.Arguments}"
Console.readLine : unit -> string option
Reads one line from standard input.
Returns None on end-of-input.
match Console.readLine () with
| Some text -> Console.writeLine $"echo: {text}"
| None -> Console.writeLine "no input"
Notes
Console.writeLineaccepts astring, so convert non-string values explicitly or use string interpolation.Console.readLineis a zero-argument function and should be called asConsole.readLine ().Console.readLinereturningNoneusually means stdin is exhausted or unavailable.- Console I/O is provided by the host runtime, not by the pure language core.
Example
Console.writeLine "What is your name?"
let greeting =
match Console.readLine () with
| Some name -> $"Hello {name}"
| None -> "Hello"
Console.writeLine greeting