Skip to main content

A simple REPL for lambda calculus

Project description

A simple REPL for lambda calculus

https://travis-ci.org/CodeGrimoire/ChurchREPL.svg?branch=master

Use:

when calling churchrepl and new REPL will be opened.

churchrepl [-f --file file [file ...]] [-v --verbose]

Flags:

(optional) Read definitions and expressions from a file before loading the normal REPL.

-f|--file file [file ...]

(optional) print debugging and verbose output.

-v|--verbose

Church repl file structure:

The EBNF grammar is as follows*:

(* church-lambda EBNF *)
                  (* --- meta --- *)
             (* line or line, line, line... *)
 program = {line};

             (* define or function *)
 line = (define | function);

             (* ex: @ID: λx.x *)
 define = "@" alias ":" function;

                  (* --- lambdas --- *)
             (* lambda or an application *)
 function = lambda | application;

             (* ex: λx.x)
 lambda = "λ" variable "." expr;

             (* ex: '(λx.x λy.y)
 application = '(' expr  expr ')';

             (* lambda or application or variable or alias *)
 expr = (lambda | application | variable | alias );

                  (* --- primitives --- *)
             (* one lowercase letter *)
 variable = /[a-z]/;

             (* one underscore or capital followed by zero
             or more [underscores, captials, or digits] *)
 alias = /[_A-Z][_A-Z0-9]*/;

A simple example program:

@ID: λx.x
@APPLY: λf.λx.(f x)
@TRUE: λx.λy.x
@FALSE: λx.λy.y
@ZERO: λf.λx.x
@SUCC: λn.λf.λx.(f ((n f) x))
@ONE: (SUCC ZERO)
@TWO: (SUCC ONE)
@THREE: (SUCC TWO)
@FOUR: (SUCC THREE)
(SUCC ZERO)
(SUCC ONE)
(SUCC TWO)
(SUCC THREE)
(SUCC FOUR)

Note: The λ (lambda, unicode u03bb) is equivalent to a backslash as far as this program is concerned. When using the repl it may be easier to use a backslash.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

churchrepl-1.0.1.post1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

churchrepl-1.0.1.post1-py2.py3-none-any.whl (9.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file churchrepl-1.0.1.post1.tar.gz.

File metadata

File hashes

Hashes for churchrepl-1.0.1.post1.tar.gz
Algorithm Hash digest
SHA256 41fbac9e1133dad5c4d9f337d7fdf61be8c2476f19afbe334dee90e7b09ef7cf
MD5 bb561ba0685841b2d6e2fe161312e4e1
BLAKE2b-256 a59beb658abe733c3ab292d6250f17a01cf40118b224784e08b93b4884d6ed87

See more details on using hashes here.

File details

Details for the file churchrepl-1.0.1.post1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for churchrepl-1.0.1.post1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d4f27a18c3df0bbef3d9238af84c71971a7d1d9aa4fb9d5aa984c5bd78863776
MD5 39f4d8f2c9f2c320651f356591cb6322
BLAKE2b-256 82081af4d2802085d03b6bf06f550d59b415ebaf0928f89263b80a6d738bcb1f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page