Examples

Clone the repository for the lessons under examples/. With pip, run python go.py in a lesson’s directory; lesson 00 uses sprite-exec on its Curry programs and lesson 24 python minimake.py or python make.py. ./run uses a staged checkout (make stage) and matches expected.out. Each lesson has a README with its scope and limits.

Start with Quickstart for lessons 01 and 02 in five minutes, then Using the API for the boundary in teaching order. The tour below is followed by applications, an optional specialist series and the build-system capstone. Each path below links to the lesson in the repository.

Tour: 00 to 09

00: Curry at the command line

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

01: Hello, both ways

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

02: Compile and parse

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

03: Metadata

examples/03-inspect — Read public module, symbol and type metadata before an explicitly internal view of compiler products. It uses interpret:off to read compiled code.

04: Session

examples/04-static-compile — Compile, reload, recognize stale terms, reset, save, load and wait for background compilation. It also runs a saved program.

05: Trees

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

06: Variables

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

07: Choices, sharing, functions

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

08: Permutation sort

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

09: Streams

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

Applications: 10 to 19 and 25

10: N queens

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

11: Sudoku

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

12: SEND + MORE = MONEY

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

13: Regular expressions

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

14: Expression parser

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

15: Dependency solver

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

16: Scheduling

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

17: Type inference

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

18: Text extraction

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

19: Blocks World application

examples/19-blocks-world-app — Search by iterative deepening behind a command line and an HTTP form.

25: Perfect hash

examples/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: C++ template deduction

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

21: C++ overload resolution

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

22: C++ trait checking

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

23: C++ member layout

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

Capstone: 24

24: A makefile in Curry

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

Support sources

examples/cxx/ holds the modules shared by lessons 20 to 23; examples/Peano.curry is the fixture of lesson 03.