Reading diagrams / Topic 6 of 42

Direct IO and tables

The rule

IO is anything a program does outside itself. In these programs that means a database. A table is stored data, rows the program reads and writes. An effect site is one place in the code that reads or writes a table. Here are two from Charter: the first names the charter_active table, and the second reads a row from it.

icetakes/app/charter.bosatsu
active_table: TxTable[s, ActiveCharter] = stored_table("charter_active")

def read_active_charter(db: Db, _: Principal) -> IO[Outcome[CharterError, Option[ActiveCharter]]]:
  _ <- transaction(db)
  tx_read(active_table, site_id)

A package marked direct IO has effect sites in its own definitions. Select it to see which tables it reads and writes.

A package without the mark has no effect site in its own code.

Icetakes, a community reading site, in full.

Loading the layer diagram.

Loading the worked examples and practice.