Various helper functions for creating simple interactive systems.
These are mostly intended for helping with teaching, in that they will allow
the easy creation of interactive programs without needing to teach IO
or Effects first, but they also capture some common patterns of interactive
programming.
Disables buffering in both stdin and stdout:
so that output is written immediately (never stored in the buffer)
and the next input item is read and returned
this is useful to circumvent problems with IO on some Windows systems
where stdout output right before a prompt is only shown after
the input-line from stdin is produced
Get the command-line arguments that the program was called with.
Read a single character from stdin
Read one line of input from stdin, without the trailing newline
Read one line of input from stdin, without the trailing newline, for any FFI
descriptor
Output something showable to stdout, without a trailing newline
Output something showable to stdout, without a trailing newline, for any FFI
descriptor
Output something showable to stdout, with a trailing newline
Output something showable to stdout, with a trailing newline, for any FFI
descriptor
Process input from an open file handle, while maintaining a state.
the input state
the function to run on reading a line, returning a String to
output and a new state
the function to run on reaching end of file, returning a String
to output
Process input from the standard input stream, while maintaining a state.
the input state
the function to run on reading a line, returning a String to
output and a new state
the function to run on reaching end of input, returning a String
to output
Write a single character to stdout
Write a single character to stdout, with a trailing newline
Output a string to stdout without a trailing newline
Output a string to stdout without a trailing newline, for any FFI
descriptor
Output a string to stdout with a trailing newline
Output a string to stdout with a trailing newline, for any FFI
descriptor
A basic read-eval-print loop
the prompt to show
the function to run on reading input, returning a String to
output
A basic read-eval-print loop, maintaining a state
the input state
the prompt to show
the function to run on reading input, returning a String to
output and a new state. Returns Nothing if the repl should exit