run.bend relies on unsafe/foreign
raw source on the hub · import cli@0.2.0.0/run.bend as Run
Purpose: the public IO shell: probes the host, runs Cli.eval, writes its output, calls act and exits (§7). The host effects live in sys.c and sys.js; no law imports this file (F1). Expected output: SOME PROOFS FAIL, listing only the defs that rely on sys.c and sys.js (F1, G2). Run: bend run.bend --check-only
2 imports
import Base import ./cli.bend as Cli
Definitions
def exit_when source · line 21 · raw
@zero:Bool -> @code:U32 -> IO(Unit)
def exit source · line 28 · raw
@+code:U32 -> IO(Unit)
0 returns, so work started with IO.fork can finish; any other code flushes stdout and ends the process at once.
def chomp_end source · line 31 · raw
@newline:Bool -> @c:Char -> String
def chomp_from source · line 37 · raw
@t:String -> @+c:Char -> String
c then t, less one final "\n".
def chomp source · line 43 · raw
@s:String -> String
s less one final "\n": IO.print_err adds it back.
def write_out source · line 48 · raw
@empty:Bool -> @out:String -> IO(Unit)
def write_err source · line 53 · raw
@empty:Bool -> @err:String -> IO(Unit)
def finish source · line 59 · raw
@code:U32 -> @+out:String -> @+err:String -> IO(Unit)
§7.2 step 4: out to stdout and err to stderr, each if not empty, then exit.
def var_found source · line 65 · raw
@name:String -> @got:Result<&1, &1, Pair(U32, String), String> -> List<&2, 0xa67b4e5d151887b6bff62a913c86b60d/cli.Var>
def read_vars source · line 72 · raw
@names:List<&2, String> -> IO(List<&2, 0xa67b4e5d151887b6bff62a913c86b60d/cli.Var>)
Each set variable among names, in order.
def host source · line 83 · raw
@c:0xa67b4e5d151887b6bff62a913c86b60d/cli.Cmd -> IO(0xa67b4e5d151887b6bff62a913c86b60d/cli.Host)
§7.3: the variables c reads, whether stdout and stderr are TTYs, and their columns; Cli.probe decides the rest.
def argv_list source · line 93 · raw
@args:List<&1, List<&2, U32>> -> List<&2, String>
def argv_of source · line 100 · raw
@args:List<&1, List<&2, U32>> -> List<&2, String>
IO.args_bytes without its head, the program as invoked, each argument decoded by Cli.arg_text, so Cli.arg_bytes gives back its bytes.
def ended source · line 106 · raw
@r:Pair(U32, String) -> IO(Unit)
§7.2 step 5: act's code, mapped by Cli.act_exit.
def wrote source · line 127 · raw
@r:0xa67b4e5d151887b6bff62a913c86b60d/cli.Ran -> IO(Unit)
Templates
template stepped source · line 110 · raw
@-A:Type -> @-act:(@+t:0xa67b4e5d151887b6bff62a913c86b60d/cli.Term -> @_:A -> IO(U32)) -> @s:0xa67b4e5d151887b6bff62a913c86b60d/cli.Step<A> -> IO(Unit)
template main source · line 120 · raw
@-A:Type -> @-decode:(@+m:0xa67b4e5d151887b6bff62a913c86b60d/cli.Matches -> 0xa67b4e5d151887b6bff62a913c86b60d/cli.Dec(A)) -> @-act:(@+t:0xa67b4e5d151887b6bff62a913c86b60d/cli.Term -> @_:A -> IO(U32)) -> @+c:0xa67b4e5d151887b6bff62a913c86b60d/cli.Cmd -> IO(Unit)
§7.2: an app's whole main.
template planned source · line 134 · raw
@-A:Type -> @-decode:(@+m:0xa67b4e5d151887b6bff62a913c86b60d/cli.Matches -> 0xa67b4e5d151887b6bff62a913c86b60d/cli.Dec(A)) -> @-plan:(@+t:0xa67b4e5d151887b6bff62a913c86b60d/cli.Term -> @_:A -> 0xa67b4e5d151887b6bff62a913c86b60d/cli.Ran) -> @+c:0xa67b4e5d151887b6bff62a913c86b60d/cli.Cmd -> IO(Unit)
§7.2: the whole main of an app whose action is a pure plan: Cli.invoke's run on the host and argv, written out, so a law on Cli.invoke states what the app prints and exits with.
Effects (foreign code)
effect Sys.isatty source · line 12 · raw
@fd:U32 -> IO(U32)
1 if fd is a terminal, else 0.
foreign: sys.c, sys.js
effect Sys.columns source · line 17 · raw
@fd:U32 -> IO(U32)
fd's terminal width in columns, or 0 if it has none.
foreign: sys.c, sys.js