Bosatsu/Prog

source code: - test_workspace/Prog.bosatsu

Index

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.

references: Prog, Var

def get[a](v: Var[a]) -> forall e: *. Prog[e, a]

get_and_update

Update a cell and return the previous value.

references: Prog, Var

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.

references: Prog, Unit, Var

def modify[a](v: Var[a], fn: a -> a) -> forall a: *. Prog[a, ()]

new_var

Allocate a fresh cell when the Prog is executed.

references: Prog, Var

def new_var[a](a: a) -> forall e: *. Prog[e, Var[a]]

observe

references: Prog, Unit

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 ().

references: Prog, Unit, Var

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.

references: Prog, Var

def swap[a](v: Var[a], new_value: a) -> forall e: *. Prog[e, a]

unit

references: Prog, Unit

unit: forall a: *. Prog[a, ()]

update

Atomically transform the current value. On some runtimes fn may be retried.

references: Prog, Tuple2, Var

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.

references: Prog, Var

def update_and_get[a](v: Var[a], fn: a -> a) -> forall b: *. Prog[b, a]