Examples

CI runs every entry with its registered arguments and checks stdout and stderr byte-for-byte; a multi-module project takes its directory.

  • run by CI, byte for byte

Basics3

  • fib

    Fibonacci two ways: naive recursion, and a tail call that becomes a loop.

  • fizzbuzz

    FizzBuzz: match guards, string interpolation and a for over a range.

  • lambdas

    Function values: lambdas, captures, higher-order functions, effect variables.

Modelling data4

  • generics

    Generics: type parameters, Option and Result, and the list builtins.

  • narrow

    Narrow floats: bfloat16 and binary16 as values that round the way the hardware rounds.

  • records

    Records: literals, field shorthand, functional update, and record patterns.

  • shapes

    Sum types and pattern matching: a Shape ADT, guards, pipes and test blocks.

Text and characters1

  • chars

    Characters and code points: making a slug, and the two renderings of a Char.

Traits2

  • eqhash

    Eq and Hash: the prelude traits behind == and hashing.

  • traits

    Traits: a default method, impls for a record and for Int, bounded generics.

Effects5

  • cells

    Handler state: a var declared in the arm table, and the block below the handler reading what the arms left there.

  • files

    The file system as a named effect: one reader, two handlers.

  • handlers

    Effect handlers: an interpreter that carries no environment parameter.

  • resumption

    One-shot resumption: an answer that arrives turns later, read as the value of a let.

  • tracking

    Effect tracking: !io in a signature, and the compiler holding you to it.

Failure1

  • barriers

    Failure in three tiers: Result with ?, catch_fault, and bracket.

Java interop1

  • interop

    Java interop, worked: the JDK's own static factories, laying out a build.

Whole programs9

  • calc

    A four-function calculator: a lexer, a precedence-climbing parser, an eval.

  • comptime_bytes

    A binary lookup table is a Bytes value, with no text encoding or boxed integer list in the final constant. The package CRC and SHA functions are also called unchanged at comptime. This example makes no speed claim for table lookup: choosing a runtime CRC algorithm still needs measurement.

  • gpu_fake

    A GPU program on a machine with no GPU: ten kernels, two sides, one handler that is a table in host memory.

  • hello_mod

    A multi-module project: one directory, three modules, no manifest.

  • json

    A pure-Dawn JSON validator, run against JSONTestSuite's 318 fixtures.

  • qualified_effects

    Qualification changes lookup, not the evidence supplied by a handler.

  • tea_dom_counter

    The whole application: a model, three messages, update and view, plus the text form of the model the wire carries between turns. No io and no host; main.dawn is the one call that connects it to one.

  • tea_dom_todo_keyed

    The pure half of the demo: model, messages, update and view. No io, no wire format, no host, so every assertion below is == on a value.

  • tea_todo

    The pure half of the todo app: model, messages, update, view, and the line parser. Everything here is a value-in, value-out function, which is what the test blocks below lean on -- an interaction is asserted as data, no terminal in sight. The io shell around it is main.dawn.