Sprite examples
===============

Run "make stage" at the repository root, then "./run" in an example's
directory.  Each numbered directory has a README, a run script and an
expected.out recording its exact stdout.  The scripts use the staged
installation or SPRITE_HOME and the flags of SPRITE_INTERPRETER_FLAGS.
The first run also compiles the Curry sources; products live under .curry/.
Rules that overlap by design silence the front-end warning in their run
script unless SPRITE_FRONTEND_WARNINGS is set explicitly.

The tour runs from 00 to 09.  Follow it with an application, the optional
C++ type series, or the build-system capstone.  The Python API guide follows
first calls, results, values and types, logic, encapsulated search, errors,
session control, and I/O; the Quickstart covers 01 and 02 in five minutes.

The test tests/unit_examples.py compares each run with expected.out.
All examples run on the C++ runtime.  Example 03 shows generated C++,
09 uses the stream channel, and 04 saves and loads objects and programs.
To record intentional output changes, run
SPRITE_UPDATE_EXPECTED=1 ./run_tests unit_examples.py from tests/ and review
the diff.  The test entries list the examples.

Tour: 00 to 09
--------------

00-run-curry-programs
    Run a call-time choice by file, module or goal with sprite-exec.

01-run-with-python
    Send Python data to Curry, consume answers and correct three boundary
    mistakes.

02-dynamic-code-generation
    Compile a Nat module from text and build goals with symbol calls and
    parse.

03-inspect
    Read public module, symbol and type metadata before an explicitly internal
    view of compiler products.

04-static-compile
    Compile, reload, recognize stale terms, reset, save, load and wait for
    background compilation.

05-trees
    Construct and match trees on either side of the boundary, then generate
    bounded shapes and a seeded tree.

06-variables
    Read named bindings from narrowing, then observe arithmetic suspension and
    resumption.

07-choices
    Compare shared and independent choices, observe a cyclic list and reuse a
    returned function.

08-permutation-sort
    Generate permutations, keep sorted ones and collect a multiset with a set
    function.

09-streams
    Pull finite output, a prime prefix and running totals from Curry I/O
    actions.


Applications: 10 to 19 and 25
-----------------------------

10-queens-set-functions
    Use a set function to reject unsafe permutations and draw a solution.

11-sudoku
    Fill the most constrained cell first so dead branches fail early.

12-cryptarithm
    Use structural permutations and lazy column checks to prune digit
    assignments.

13-regex-nondeterminism
    Generate words as nondeterministic values and match by unification.

14-parser-functional-patterns
    Split input with functional patterns and let failure prune parses.

15-dependency-solver
    Search Python package data, pin a preferred plan and explain a failed
    resolution.

16-scheduling
    Constrain task start times with guards and minimize the resulting
    makespan.

17-type-inference
    Treat unknown types as free variables and infer them by unification.

18-text-extraction
    Compile extraction rules at run time and aggregate their answers in
    Python.

19-blocks-world-app
    Search by iterative deepening behind a command line and an HTTP form,
    succeeding the retired Flask example.

25-perfect-hash
    Search programs by length for a Java-keyword hash beside Python brute
    force over the same space.


Optional C++ type series: 20 to 23
----------------------------------

20-cxx-types-deduction
    Deduce template parameters by unification and ask the inverse question
    over bounded types.

21-cxx-types-overloads
    Collect viable conversions and search for argument types that make a call
    ambiguous.

22-cxx-types-trait-check
    Collect counterexamples to a trait within a bounded type universe.

23-cxx-types-layout
    Search member orders for a smaller layout under an extra ordering
    constraint.


Capstone: 24
------------

24-build-system
    Query a build relation in several directions while Python owns timestamps
    and recipe execution.

Support sources
---------------

cxx/ holds the type algebra, LP64 tables, conversions, trait checks and
layout rules shared by 20 to 23.  Peano.curry is the small shared metadata
fixture of 03.  These support sources have no separate run or expected.out.
The only Nat introduction is 02.
