Skip to content
Halyard
Project
Source code on Codeberg (opens in new tab)

Search

Menu

Process Module

Process control, environment, and timing operations.

Functions

Process.args

() ->{Proc} [String]

Return the command-line arguments passed to the program.

Example:
halyard
import Process

Process.args ()

-- ["arg1", "arg2", ...]

Notes: Excludes the program name. Takes Unit to trigger execution.

See also: Process.env

Process.env

String ->{Proc} Maybe String

Get the value of an environment variable.

Example:
halyard
import Process

Process.env "PATH"

-- Just "/usr/bin:..."

See also: Process.setEnv, Process.args

Process.exit

Int ->{Proc} ()

End the program with the given exit code.

Example:
halyard
import Process

Process.exit 0

Notes: This function never returns. A script run with halyard run ends its process with the code; in the REPL, a notebook or the playground only the current cell ends, and the session keeps running.

Process.hostname

() ->{Proc} String

Return the hostname of the machine running the current process.

Example:
halyard
import Process

Process.hostname ()

-- e.g. "myhost"

Notes: Returns "unknown" if the hostname cannot be determined. Takes Unit to trigger execution.

See also: Process.pid

Process.pid

() ->{Proc} Int

Return the process ID of the current process.

Example:
halyard
import Process

Process.pid ()

-- e.g. 12345

Notes: Takes Unit to trigger execution.

See also: Process.hostname

Process.setEnv

String -> String ->{Proc} ()

Set an environment variable. HALYARD_* variables cannot be set.

Example:
halyard
import Process

Process.setEnv "MY_VAR" "my_value"

Notes: Changes only affect the current process. Setting HALYARD_* variables is an error.

See also: Process.env

Process.uptime

() ->{Proc} Int

Return the number of milliseconds since the current program began executing.

Example:
halyard
import Process

Process.uptime ()

-- e.g. 42

Notes: Takes Unit to trigger execution.

See also: Process.wait

Process.wait

Int ->{Proc} ()

Sleep for the given number of milliseconds. Blocks the current thread.

Example:
halyard
import Process

Process.wait 500

Notes: Negative values are treated as zero.

See also: Process.uptime