Sys

Imports
open Array; open Map;
Table of Contents

Functions

sys

def sys : Unit

os

def os : Unit

argv

The list of command-line arguments. argv[0] is the program name, so the list is always non-empty.
def argv (_ : Unit) : {l : Array String | Array.size l ≥ 1}

args

Command-line arguments without the program name. May be empty.
def args (_ : Unit) : Array String

argc

The number of command-line arguments. Always >= 1 (argv[0] is the program).
def argc : {x : Int | x ≥ 1}

progName

The program name (argv[0]).
def progName : String

exit

Exits the process. Conventionally 0 = success, 1-255 = error.
def exit (code : Int | code ≥ 0 && code ≤ 255) : Unit

readLine

Reads a line from stdin (newline stripped). Thunked to defer the read.
def readLine (_ : Unit) : String

eprint

Prints a string to stderr followed by a newline.
def eprint (s : String) : Unit

flushStdout

Flushes the standard output buffer.
def flushStdout (_ : Unit) : Unit

flushStderr

Flushes the standard error buffer.
def flushStderr (_ : Unit) : Unit

environ

Returns a snapshot of the current environment as a Map.
def environ (_ : Unit) : Map String String

getenv

Looks up an environment variable, returning default if unset.
def getenv (name : String | name ≠ "") (default : String) : String

hasenv

Returns true if the environment variable is set.
def hasenv (name : String | name ≠ "") : Bool

setenv

Sets an environment variable and returns a snapshot of the new environment.
def setenv (name : String | name ≠ "") (value : String) : Map String String

platform

A string identifying the platform (e.g. "linux", "darwin", "win32").
def platform : String

pythonVersion

The Python version string of the underlying interpreter.
def pythonVersion : String

executable

The path to the Python executable.
def executable : String