From 7336b25d74ad0d8b3b15444582afc082ee30562a Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Mon, 30 Sep 2024 15:07:30 +0200 Subject: Add some documentation and a sample for pairs --- .gitignore | 2 ++ rust/README.md | 21 +++++++++++++++++++++ rust/sample/test02/input | 6 ++++++ rust/sample/test02/output | 4 ++++ 4 files changed, 33 insertions(+) create mode 100644 .gitignore create mode 100644 rust/README.md create mode 100644 rust/sample/test02/input create mode 100644 rust/sample/test02/output diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51e3dbd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.profraw diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 0000000..7ea2db6 --- /dev/null +++ b/rust/README.md @@ -0,0 +1,21 @@ +# Rust λ-calcul reference implementation + +This directory contains a reference implementation of a normal order semantics λ-calculus based language. +Current syntax is based on S-expressions, ie. Lisp. There is a command-line interpreter for batch and interactive evaluation of input, and an embryonic tester daemon. + +# Tester + +**NOTE**: This is a work-in-progress, current tester is only capable of running program locally through a forked process + +The tester daemon is inspired by [Extreme Startup](https://github.com/rchatley/extreme_startup): It's a REST-ish server and client that allows to repeatedly send λ-terms to a remote execution engine and compare the result against its expectations. + +The interaction flow is simple: + +* The server listens on a well-known port +* A client connects to this port and requests a test session (`POST /register`), giving a URL to callback, +* The server returns an identification token, to passed to and from the client in subsequent calls, +* Then the server repeatedly sends requests to the client (`POST /eval`) whose body is a S-expr representing a λ-term, and it expects an evaluation result. + * Note the evaluation can return error if the term is syntactically malformed + * The server waits at most 60 seconds for the answer +* If the client fails to answer, or answers wrongly, the server keeps sending the same request +* If the client's answer is correct, the server sends another term, more complex, to evaluate. diff --git a/rust/sample/test02/input b/rust/sample/test02/input new file mode 100644 index 0000000..81a0443 --- /dev/null +++ b/rust/sample/test02/input @@ -0,0 +1,6 @@ +(def pair (lam (a b f) (f a b))) + +(def fst (lam p (p (lam ( a b) a)))) +(def snd (lam p (p (lam ( a b) b)))) + +(fst (snd (pair 1 (pair 2 0)))) diff --git a/rust/sample/test02/output b/rust/sample/test02/output new file mode 100644 index 0000000..c61e10e --- /dev/null +++ b/rust/sample/test02/output @@ -0,0 +1,4 @@ +true +true +true +2 -- cgit v1.2.3