Cookbook

Small recipes, warm from the oven.

Short, complete programs for everyday tasks. Copy one, run it, change it.

Basics

3 recipes
Beginner · Coming soon

Read command-line arguments

Match on env.args() to build a tiny command.

pooka/env
Beginner · Coming soon

Parse a number safely

Turn text into an Int without crashing on bad input.

pooka/intResult
Beginner · Coming soon

Match on the shape of a list

Empty, one, many: let patterns do the counting.

match

Strings and text

3 recipes
Beginner

Count words in a file

Read a file, split it into words and print the most common ones.

pooka/filepooka/dict
Beginner · Coming soon

Split, trim and join

The everyday string toolkit, in one pipeline.

pooka/string
Intermediate · Coming soon

Write a tiny lexer

Generate a typed lexer from a TOML description with lexie.

lexie

Collections

3 recipes
Beginner · Coming soon

Count things with a Dict

Tally values with upsert, then read them back sorted.

pooka/dict
Beginner · Coming soon

Sort by a key

Order classes by any field with list.sort_by.

pooka/listpooka/order
Intermediate · Coming soon

Fold a list into a summary

One pass, many answers: totals, minimums and counts.

list.fold

Files and processes

3 recipes
Beginner · Coming soon

Read and write files

Load, change and save a file, handling every FileError.

pooka/file
Beginner · Coming soon

List a directory

Walk a folder and keep only the files you want.

pooka/filepooka/path
Intermediate · Coming soon

Run a shell command

Call another program and read its output and exit status.

pooka/process

Actors and concurrency

3 recipes
Beginner · Coming soon

A counter actor

Keep changing state safely inside an actor's mailbox.

actorbe
Intermediate · Coming soon

Fan work out to actors

Start several workers and gather their answers.

actor
Advanced · Coming soon

Supervise a worker

Restart a crashed process with pooka/otp.

pooka/otp

Interop

3 recipes
Beginner · Coming soon

Call an Erlang function

Describe it once in an external block, call it like Pooka.

external
Intermediate · Coming soon

Use an Elixir or Gleam package

Add it from Hex and give it a typed front door.

pooka add
Advanced · Coming soon

Serve HTTP with Cowboy

A small web server in a page of Pooka.

cowboy

Testing

2 recipes
Beginner · Coming soon

Write your first test

test blocks, assert and pooka test.

testassert
Beginner · Coming soon

Test many cases in a loop

Table-driven tests with loop and labelled assertions.

loopassert … as

Have a recipe to share?

A recipe is one Markdown file in src/cookbook/ with one complete program that compiles with the current release. Send it as a pull request.