Bosatsu/Prog
source code: - test_workspace/Prog.bosatsu
Index
- Types:
Main,Prog,ProgTest,Var - Values:
await,get,get_and_update,ignore_err,map,map_err,modify,new_var,observe,pure,raise_error,recover,recursive,set,swap,unit,update,update_and_get
Types
Main
type Main
Constructors
Main(run: List[String] -> forall err: *. Prog[err, Int])
Prog[err, res]
type Prog[err: +*, res: +*]
ProgTest
type ProgTest
Constructors
ProgTest(test_fn: List[String] -> forall err: *. Prog[err, Test])
Var[a]
Var is an effectful mutable cell. The type parameter is invariant.
type Var[a: ๐ป*]
Values
await
references: Prog
def await[a, b, c](p: Prog[a, b], fn: b -> Prog[a, c]) -> Prog[a, c]
get
Read the current value in the cell.
def get[a](v: Var[a]) -> forall e: *. Prog[e, a]
get_and_update
Update a cell and return the previous value.
def get_and_update[a](v: Var[a], fn: a -> a) -> forall b: *. Prog[b, a]
ignore_err
references: Prog
def ignore_err[a, b](prog: Prog[a, b], default: b) -> forall a: *. Prog[a, b]
map
references: Prog
def map[a, b, c](prog: Prog[a, b], fn: b -> c) -> Prog[a, c]
map_err
references: Prog
def map_err[a, b, c](prog: Prog[a, b], fn: a -> c) -> Prog[c, b]
modify
Update a cell and discard the projected result.
def modify[a](v: Var[a], fn: a -> a) -> forall a: *. Prog[a, ()]
new_var
Allocate a fresh cell when the Prog is executed.
def new_var[a](a: a) -> forall e: *. Prog[e, Var[a]]
observe
def observe[a](a: a) -> forall err: *. Prog[err, ()]
pure
references: Prog
def pure[err, res](a: res) -> Prog[err, res]
raise_error
references: Prog
def raise_error[err, res](e: err) -> Prog[err, res]
recover
references: Prog
def recover[err, res, err1](prog: Prog[err, res], fn: err -> Prog[err1, res]) -> Prog[err1, res]
recursive
references: Prog
def recursive[a, b, c](fn: (a -> Prog[b, c]) -> a -> Prog[b, c]) -> a -> Prog[b, c]
set
Store a new value in the cell and return ().
def set[a](v: Var[a], value: a) -> forall e: *. Prog[e, ()]
swap
Store a new value in the cell and return the previous value.
def swap[a](v: Var[a], new_value: a) -> forall e: *. Prog[e, a]
unit
unit: forall a: *. Prog[a, ()]
update
Atomically transform the current value. On some runtimes fn may be retried.
def update[a, b](v: Var[a], fn: a -> (a, b)) -> forall e: *. Prog[e, b]
update_and_get
Update a cell and return the new value.
def update_and_get[a](v: Var[a], fn: a -> a) -> forall b: *. Prog[b, a]