A small street needs neighbours

A compiler can spend a surprisingly long time congratulating itself for adding two numbers.

Eventually somebody asks it to read a configuration file, send a request, or keep a process alive. The little workshop needs a street around it. Pooka's street now has a few more neighbours.

The name on the parcel

There are three names worth keeping straight: the package you install, the repository you visit, and the module you import.

Package Repository Import
pooka_otp otp pooka/otp
pooka_json json pooka/json
pooka_http http pooka/http
pooka_httpc httpc pooka/httpc
tome tome tome

The official libraries share the pooka/ doorway. Tome lives on my own shelf. All five have reached their first 1.0.0 releases on Hex, with documentation beside them.

A small configuration file

Tome reads TOML into a family of values that Pooka can check:

module main

import tome

main() {
  let assert Ok(config) = tome.parse("[server]\nport = 8080")
  let assert Some(value) = tome.path(config, ["server", "port"])
  assert tome.as_int(value) == Some(8080)
}

An integer stays an integer. A missing field stays missing. If the document cannot be read, the parser returns an error with a line number.

There are 735 tests behind Tome, including the TOML 1.0 conformance cases. Configuration looks quiet until you ask what an escaped quote means inside a dotted key. Then the furniture begins to move.

A request before its journey

The HTTP vocabulary is separate from the client that sends it:

module main

import pooka/http

main() {
  let assert Ok(request) = http.get("https://example.org/birds?q=owl")
  assert request.query_param("q") == Some("owl")
  assert request.validate() == Ok(Nil)
}

This example builds a value. It opens no connection. pooka/httpc sends requests and returns the same response type a server can use.

That shared vocabulary gives libraries room to cooperate without owning each other. A handler can be tested with ordinary request values. A client can report a transport failure separately from an HTTP response with status 404.

Writing these libraries has also given the compiler better homework: imported interfaces, generic callbacks, error propagation and real processes. Small examples establish the spelling. Libraries discover where the spelling was hiding an assumption.

The package shelf and Tome documentation have the longer introductions. I would like these neighbours to be useful enough that people stop thinking about the compiler for a while.

That would be a respectable afternoon's work.

— Peregrine Finch

· pooka · libraries · beam