Yichus/Data
Builtin package (resource data.bosatsu).
This is the complete package source used by this build. The export
list names its public API; definitions below give the types and behavior.
New to the API? Start with Make a calculator or Build an API, then use this page to look up a definition.
package Yichus/Data from Bosatsu/Predef import Int, String, List, Unit, Option from Yichus/IO import IO, pure export ( Db, Table, table, db_next_id, db_read, db_read_opt, db_write, db_create, db_delete, db_query, batch ) exposes Yichus/IO external type Db # A table both reads and writes a, so its row type is invariant. external type Table[a: *] external def table[a](db: Db, name: String) -> Table[a] external def db_next_id[a](tbl: Table[a]) -> IO[String] external def db_read[a](tbl: Table[a], id: String) -> IO[a] # A read that says when the row is missing. `db_read` of a missing id # yields the empty list, which is only a well-typed value for a # `Table[List[a]]`; a record table reads through `db_read_opt` and # matches `None`. external def db_read_opt[a](tbl: Table[a], id: String) -> IO[Option[a]] external def db_write[a](tbl: Table[a], id: String, value: a) -> IO[a] external def db_create[a](tbl: Table[a], value: a) -> IO[a] external def db_delete[a](tbl: Table[a], id: String) -> IO[Unit] external def db_query[a](tbl: Table[a]) -> IO[List[a]] external def batch[a, b](key: String, request: a, resolver: List[a] -> IO[List[b]]) -> IO[b] # Keep Prog import live at term level to satisfy Bosatsu unused-import checks. io_marker = pure(())