Previous Up Next

Chapter 4  Console I/O

The ConsoleIO module provides access to the ``console'' used to run command-line programs. This module is defined in the ``console-io'' library. It has the following signature:
val getCommandName : () -> String
val getCommandArgs : () -> List(String)
val getEnv : String -> Option(String)
val print : String -> ()
val printChr : Char -> ()
val inputLine : () -> String
The console I/O operations have the following semantics:
getCommandName

This function returns the name of the program being executed (i.e., argv[0] in Unix systems).
getCommandArgs

This function returns a list of the command-line arguments that were supplied by the user. This list does not include arguments used to control properties of the Moby runtime system.
getEnv

This function looks its argument in the executing program's execution environment. It returns None if the variable is not defined and returns Some(s) if the argument is bound to the value s.
print

This function prints its argument on the standard output stream associated with the console.
printChr

This function prints its argument on the standard output stream associated with the console.
inputLine

This function reads a line of input from the standard input associated with the console. The empty string is returned on end-of-file.

Previous Up Next