on master help sign in
Add section on package creation, and typo fixes.

This commit address #2032, and addes information about package creation. This content is taken from the Idris website. Other typographic fixes for use with reST syntax are fixed.

commit454ec21c3c820ce055148ce4bfd85ef24c186a9a authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateSun 22 Mar 2015, 12:42 (12 years ago) parent84fa0bb
5 files changed+85−6
docs/index.rst+1 docs/reference/erasure.rst+4−4 docs/tutorial/index.rst+1 docs/tutorial/packages.rst+77 docs/tutorial/typesfuns.rst+2−2
docs/index.rst+1
@@ -35,6 +35,7 @@ The Idris Tutorial
3535 tutorial/typesfuns
3636 tutorial/classes
3737 tutorial/modules
38+ tutorial/packages
3839 tutorial/interp
3940 tutorial/views
4041 tutorial/theorems
docs/reference/erasure.rst+4−4
@@ -94,11 +94,11 @@ cannot get below O(n) with time complexities.
9494One could argue that Idris in fact compiles ``Nat`` via GMP but
9595that's a moot point for two reasons:
9696
97−* First, whenever we try to index our datastructures with anything
98−else than ``Nat``, the compiler is not going to come to the rescue.
97++ First, whenever we try to index our datastructures with anything
98+ else than ``Nat``, the compiler is not going to come to the rescue.
9999
100−* Second, even with ``Nat``, the GMP integers are *still* there and
101−they slow the runtime down.
100++ Second, even with ``Nat``, the GMP integers are *still* there and
101+ they slow the runtime down.
102102
103103This ought not to be the case since the ``Nat`` are never used at
104104runtime and they are only there for typechecking purposes. Hence we
docs/tutorial/index.rst+1
@@ -23,6 +23,7 @@ The is the Idris Tutorial. It will teach you about programming in the Idris Lang
2323 typesfuns
2424 classes
2525 modules
26+ packages
2627 interp
2728 views
2829 theorems
docs/tutorial/packages.rstnew file+77
@@ -0,0 +1,77 @@
1+.. _sect-packages:
2+
3+========
4+Packages
5+========
6+
7+``Idris`` includes a simple system for building packages from a
8+package description file. These files can be used with the ``Idris``
9+compiler to manage the development process of your ``Idris``
10+programmes and packages.
11+
12+Package Descriptions
13+--------------------
14+
15+A package description includes the following:
16+
17++ A header, consisting of the keyword package followed by the package name.
18++ Fields describing package contents, ``<field> = <value>``
19+
20+At least one field must be the modules field, where the value is a
21+comma separated list of modules. For example, a library test which
22+has two modules ``foo.idr`` and ``bar.idr`` as source files would be
23+written as follows::
24+
25+ package foo
26+
27+ modules = foo, bar
28+
29+Other examples of package files can be found in the ``libs`` directory
30+of the main ``Idris`` repository, and in `third-party libraries <https://github.com/idris-lang/Idris-dev/wiki/Libraries>`_.
31+
32+Other common fields which may be present in an ``ipkg`` file are:
33+
34++ ``sourcedir = <dir>``, which gives the directory (relative to the
35+ current directory) which contains the source. Default is the current
36+ directory.
37+
38++ ``executable = <output>``, which gives the name of the executable
39+ file to generate.
40+
41++ ``main = <module>``, which gives the name of the main module, and
42+ must be present if the executable field is present.
43+
44++ ``opts = "<idris options>"``, which allows options (such as other
45+ packages) to be passed to ``Idris``.
46+
47+In more advanced cases, particularly to support creating bindings to
48+external ``C`` libraries, the following options are available:
49+
50++ ``makefile = <file>``, which specifies a ``Makefile``, to be built
51+ before the ``Idris`` modules, for example to support linking with a
52+ ``C`` library.
53+
54++ ``libs = <libs>``, which gives a comma separated list of libraries
55+ which must be present for the package to be usable.
56+
57++ ``objs = <objs>``, which gives a comma separated list of additional
58+ object files to be installed, perhaps generated by the ``Makefile``.
59+
60+Using Package files
61+-------------------
62+
63+Given an ``Idris`` package file ``text.ipkg`` it can be used with the ``Idris`` compiler as follows:
64+
65++ ``idris --build test.ipkg`` will build all modules in the package
66+
67++ ``idris --install test.ipkg`` will install the package, making it
68+ accessible by other ``Idris`` libraries and programs.
69+
70++ ``idris --clean test.ipkg`` will delete all intermediate code and
71+ executable files generated when building.
72+
73+Once the test package has been installed, the command line option
74+``--package test`` makes it accessible (abbreviated to ``-p test``).
75+For example::
76+
77+ idris -p test Main.idr
docs/tutorial/typesfuns.rst+2−2
@@ -958,10 +958,10 @@ matching ``let`` and lambda bindings. It will *only* work if:
958958Dependent Records
959959-----------------
960960
961−*Records* are data types which collect several values (the record’s
961+*Records* are data types which collect several values (the record's
962962*fields*) together. ``Idris`` provides syntax for defining records and
963963*automatically generating field access and update functions. For
964−*example, we can represent a person’s name and age in a record:
964+*example, we can represent a person's name and age in a record:
965965
966966.. code-block:: idris
967967