1. PureLang
  2. Untitled project
  3. pure-lang


pure-lang / pure / README

PURE - The Pure programming language.
==== = ==============================

Pure is a functional programming language based on term rewriting. It has a
modern syntax featuring curried function applications, lexical closures and
equational definitions with pattern matching, and thus is somewhat similar to
languages of the Haskell and ML variety. But Pure is also a very dynamic
language, and is more like Lisp in this respect. The interpreter has an LLVM
backend to do JIT compilation, hence programs run blazingly fast and
interfacing to C modules is easy.

----- -- --- --

You can find tarballs, binary packages and the source repository at


Unless explicitly stated otherwise, this software is Copyright (c) 2008-2013
by Albert Graef. Please see the source for the copyright and license notes
pertaining to individual source files.

Pure comes with a fairly liberal license which lets you distribute your own
Pure programs and extensions under a license of your choice and permits
linking of commercial applications against the Pure runtime and the Pure
standard library without requiring special permission. Moreover, the Pure
interpreter (the 'pure' main program), the Pure runtime library ('libpure')
and the Pure standard library (the Pure scripts in the 'lib' folder) are
distributed as free software, and you are welcome to modify and redistribute
them under the appropriate license terms, as detailed below.

(The above explanations are not legal advice. Please read the full text of the
licenses and consult qualified professional counsel for an interpretation of
the license terms as they apply to you.)

The *Pure interpreter* is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

The *Pure runtime library* and the *Pure standard library* are also free
software: you can redistribute them and/or modify them under the terms of the
GNU *Lesser* General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later

Pure is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR

Please see the accompanying COPYING and COPYING.LESSER files for the precise
license terms. Online copies of the GPL and LGPL are also available at

------- ---- ----- --------

In addition to the above license conditions we also grant the special
permission to link code distributed under GPLv2 *only* (that is, version 2 of
the GNU General Public License without the "or later" clause) with the Pure
runtime library and the Pure standard library.

This is a temporary measure to enable interoperability with software which,
for whatever reason, is still distributed under the GPLv2 only (such as
Gnumeric), and may be revoked in future Pure releases when all relevant
software has migrated to GPLv3-compatible licenses.

-------------- ---------

The distribution also contains some non-copylefted sources which can be used
in both open source and commercial applications, usually under the terms of
the new (a.k.a. 3-clause) BSD license:

- pure_norl.cc is a version of the interpreter main program without readline
  support, which can be used as a starting point for alternate interpreter

- The sample programs in the examples subdirectory. (Please see the COPYING
  files in examples and its subdirectories for details.)

Please also check the corresponding source files for additional licensing
information and pertaining copyrights.

---- -------

Pure uses LLVM (http://llvm.org) as its compiler backend. LLVM is under
Copyright (c) 2003-2011 by the University of Illinois at Urbana-Champaign,
and is licensed under a 3-clause BSD-style license, please read COPYING.LLVM
included in the distribution for the exact licensing terms. You can also find
the LLVM license at http://llvm.org.


Please see the INSTALL file for detailed instructions. On most Unix-like
systems, './configure --enable-release && make && sudo make install' should do
the trick. This requires GNU make and g++. For other setups, you'll probably
have to fiddle with the Makefile and the sources. You'll also need LLVM for
the compiler backend. LLVM 2.5 or later is required with recent Pure versions.
For your convenience, instructions for installing LLVM are also included in
the INSTALL file.

After installing the interpreter, you should also install the online
documentation to make the 'help' command work in the interpreter. If you have
a working internet connection and the 'wget' program, this can be done with
the command 'sudo make install-docs'. Again, please check the INSTALL file for

----- ----

To start the Pure interpreter, just type 'pure' at the command prompt. You'll
be greeted with a sign-on message, after which the interpreter leaves you at
its prompt and you can start typing definitions and expressions to be
evaluated. Use the 'quit' command to exit the interpreter (on most systems you
can also just type EOF a.k.a. Ctrl-D at the beginning of the interpreter's
command line). For instance:

Pure 0.47 (x86_64-unknown-linux-gnu) Copyright (c) 2008-2011 by Albert Graef
(Type 'help' for help, 'help copying' for license information.)
Loaded prelude from /usr/local/lib/pure/prelude.pure.

> fact n = if n>0 then n*fact (n-1) else 1;
> map fact (1..10);
> quit

Of course, you can also put your definitions into a script and run that script
from the command line:

$ pure -x factorial.pure

Add the -i option to force interactive mode when executing a script, and -q to
suppress the sign-on message:

$ pure -i -q -x factorial.pure

Or you can compile your script to a native executable:

$ pure -c factorial.pure -o factorial
$ ./factorial

Pure scripts are just ordinary text files, which can be created with any text
editor. The distribution contains some language definition files and
programming modes to provide syntax highlighting in various popular text
editors, such as Emacs, Gedit, Kate and Vim. The Emacs mode also lets you run
the Pure interpreter in an Emacs buffer, this is probably the most convenient
interface to the interpreter if you're friends with Emacs. Syntax files for
Andre Simon's highlight program and the Pygments highlighter are also
included, these let you pretty-print Pure source in various output formats
such as HTML and LaTeX. You can find all this stuff in the etc subdirectory in
the source distribution, installation instructions are included in the syntax

Online documentation is available in the form of a (brief) Unix manual page
and an extensive manual in html format which contains detailed information on
the Pure language, the interpreter, the standard library and all available
addon modules and libraries. You can invoke the manpage with 'man pure' after
installation, and the online manual by using the 'help' command inside the
interpreter. The former needs the 'man' program, the latter a html browser,
w3m by default. See the INSTALL file or the manpage for details. Or just point
your browser at the following URL to read the manual on the web:


Some example programs can be found in the examples subdir in the sources; in
particular, have a look at the hello.pure program which will quickly give you
an idea how Pure programs look like. You can also browse the scripts in the
lib directory, in particular prelude.pure and the modules included there,
which contain the "built-in" definitions readily available when you start up
the Pure interpreter.

Further documentation including a wiki is available at:

You're also invited to join the Pure mailing list at:

Enjoy! :)

Albert Graef
Dept. of Computer Music
Johannes Gutenberg University of Mainz

<Dr.Graef at t-online.de>