on master help sign in
Merge pull request #4783 from buzden/reference-docs-corrections

Corrections in the `docs/reference`

commit7d34ebc5d918195f9a554196b8b84deb39911426 authorNiklas Larsson <metaniklas@gmail.com> dateMon 25 Nov 2019, 14:43 (7 years ago) parent8526a9f2f0f04c
6 files changed+57−51
docs/reference/codegen.rst+2 docs/reference/compilation.rst+15−15 docs/reference/erasure.rst+1−1 docs/reference/ffi.rst+7−6 docs/reference/internals.rst+31−28 docs/reference/uniqueness-types.rst+1−1
docs/reference/codegen.rst+2
@@ -1,3 +1,5 @@
1+.. _code-generation-targets:
2+
13************************
24Code Generation Targets
35************************
docs/reference/compilation.rst+15−15
@@ -54,7 +54,7 @@ by setting a verbosity level.
5454 Checking, and the individual steps prior to code generation.
5555
5656
57−By default Idris' progress reporting is set to quiet-``-q``, or ``--quiet``.
57+By default Idris' progress reporting is set to quiet: ``-q``, or ``--quiet``.
5858
5959Logging Internal Operation
6060===========================
@@ -100,32 +100,32 @@ Environment Variables
100100Several paths set by default within the Idris compiler can be
101101overridden through environment variables. The provided variables are:
102102
103−* `IDRIS_CC` Change the `C` compiler used by the `C` backend.
104−* `IDRIS_CFLAGS` Change the `C` flags passed to the `C` compiler.
105−* `TARGET` Change the target directory i.e. `data dir` where Idris installs files when installing using Cabal/Stack.
106−* `IDRIS_LIBRARY_PATH` Change the location of where installed packages are found/installed.
107−* `IDRIS_DOC_PATH` Change the location of where generated idrisdoc for packages are installed.
103+* ``IDRIS_CC`` Change the *C compiler* used by the *C backend*.
104+* ``IDRIS_CFLAGS`` Change the *C flags* passed to the *C compiler*.
105+* ``TARGET`` Change the target directory i.e. *data dir* where Idris installs files when installing using Cabal/Stack.
106+* ``IDRIS_LIBRARY_PATH`` Change the location of where installed packages are found/installed.
107+* ``IDRIS_DOC_PATH`` Change the location of where generated idrisdoc for packages are installed.
108108
109109.. note::
110110
111111 In versions of Idris prior to 0.12.3 the environment variables
112− `IDRIS_LIBRARY_PATH` and `TARGET` were both used to affect the
112+ ``IDRIS_LIBRARY_PATH`` and ``TARGET`` were both used to affect the
113113 installation of single packages and direct where Idris installed
114114 its data. The meaning of these variables has changed, and command
115115 line options are preferred when changing where individual packages
116116 are installed.
117117
118−The CLI option `--ibcsubdir` can be used to direct where generated IBC
118+The CLI option ``--ibcsubdir`` can be used to direct where generated IBC
119119files are placed. However, this means Idris will install files in a
120120non-standard location separate from the rest of the installed
121−packages. The CLI option `--idrispath <dir>` allows you to add a
121+packages. The CLI option ``--idrispath <dir>`` allows you to add a
122122directory to the library search path; this option can be used multiple
123−times and can be shortened to `-i <dir>`. Similary, the `--sourcepath
124−<dir>` option can be used to add directories to the source search
125−path. There is no shortened version for this option as `-s` is a
123+times and can be shortened to ``-i <dir>``. Similary, the ``--sourcepath
124+<dir>`` option can be used to add directories to the source search
125+path. There is no shortened version for this option as ``-s`` is a
126126reserved flag.
127127
128128Further, Idris also supports options to augment the paths used, and
129−pass options to the code generator backend. The option `--cg-opt
130−<ARG>` can be used to pass options to the code generator. The format
131−of `<ARG>` is dependent on the selected backend.
129+pass options to the code generator backend. The option ``--cg-opt
130+<ARG>`` can be used to pass options to the code generator. The format
131+of ``<ARG>`` is dependent on the selected backend.
docs/reference/erasure.rst+1−1
@@ -269,7 +269,7 @@ Usage warnings are quite bad and unhelpful at the moment. We should
269269include more information and at least translate argument numbers to
270270their names.
271271
272−There is no decent documentation yet. This wiki page is the first one.
272+There is no decent documentation yet. This page is the first one.
273273
274274There is no generally accepted terminology. We switch between
275275"dotted", "unused", "erased", "irrelevant", "inaccessible", while each
docs/reference/ffi.rst+7−6
@@ -204,9 +204,10 @@ unable to pass the closed-over values through C. If we want to pass Idris values
204204to the callback we have to pass them through C explicitly. Non-primitive Idris
205205values can be passed to C via the ``Raw`` type.
206206
207−The other big limitation is that it doesn't support IO functions. Use
208−``unsafePerformIO`` to wrap them (i.e. to make an IO function usable as a callback, change the return type
209−from IOr to r, and change the = do to = unsafePerformIO $ do).
207+The other big limitation is that it doesn't support ``IO`` functions. Use
208+``unsafePerformIO`` to wrap them (i.e. to make an ``IO`` function usable as a
209+callback, change the return type from ``IO r`` to ``r``, and change the ``= do``
210+to ``= unsafePerformIO $ do``).
210211
211212There are two special function names:
212213``%wrapper`` returns the function pointer that wraps an Idris function. This
@@ -258,7 +259,7 @@ useful to access constants that are preprocessor definitions (like ``INT_MAX``).
258259 main = print !intMax
259260
260261For more complicated interactions with C (such as reading and setting fields
261−of a C struct), there is a module CFFI available in the contrib package.
262+of a C ``struct``), there is a module C FFI available in the contrib package.
262263
263264C heap
264265------
@@ -371,7 +372,7 @@ Usage from C code
371372The ``Raw`` type constructor allows you to access or return a runtime
372373representation of the value. For instance, if you want to copy a string
373374generated from C code into an Idris value, you may want to return a
374−``Raw String``instead of a ``String`` and use ``MKSTR`` or ``MKSTRlen`` to
375+``Raw String`` instead of a ``String`` and use ``MKSTR`` or ``MKSTRlen`` to
375376copy it over.
376377
377378.. code-block:: idris
@@ -393,7 +394,7 @@ FFI implementation
393394------------------
394395
395396In order to write bindings to external libraries, the details of how
396−``foreign`` works are unnecessary --- you simply need to know that
397+``foreign`` works are unnecessary: you simply need to know that
397398``foreign`` takes an FFI descriptor, the function name, and its
398399type. It is instructive to look a little deeper, however:
399400
docs/reference/internals.rst+31−28
@@ -10,8 +10,8 @@ free to contribute.
1010This document assumes that you are already familiar with Idris. It is
1111intended for those who want to work on the internals.
1212
13−People looking to develop new back ends may want to look at [[Idris back
14−end IRs\|Idris-back-end-IRs]]
13+People looking to develop new back ends may want to look at
14+:ref:`code-generation-targets`
1515
1616Core/TT.hs
1717==========
@@ -53,7 +53,7 @@ with ``SC`` and ``CaseAlt`` to get GHC to generate a function for
5353mapping over contained terms.
5454
5555Constructor cases (``ConCase`` in ``CaseAlt``) refer to numbered
56−constructors. Every constructor is numbered 0,1,2,…. At this stage in
56+constructors. Every constructor is numbered *0,1,2,…*. At this stage in
5757the compiler, the tags are datatype-local. After defunctionalization,
5858however, they are made globally unique.
5959
@@ -91,12 +91,12 @@ dictionary which makes totality checking easier.
9191The ``normalise*`` functions give different behaviors - but
9292``normalise`` is the most common.
9393
94−``normaliseC`` - "resolved" means with names converted to de Bruijn
95−indices as appropriate.
94+- ``normaliseC`` - "resolved" means with names converted to de Bruijn
95+ indices as appropriate;
9696
97−``normaliseAll`` - reduce everything, even if it's non-total
97+- ``normaliseAll`` - reduce everything, even if it's non-total;
9898
99−``normaliseTrace`` - special-purpose for debugging
99+- ``normaliseTrace`` - special-purpose for debugging.
100100
101101``simplify`` - reduce the things that are small - the list argument is
102102the things to not reduce.
@@ -110,8 +110,8 @@ Core/Elaborate.hs
110110=================
111111
112112Idris definitions are elaborated one by one and turned into the
113−corresponding TT. This is done with a tactic language as an EDSL in the
114−Elab monad (or Elab' when there's a custom state).
113+corresponding ``TT``. This is done with a tactic language as an EDSL in the
114+``Elab`` monad (or ``Elab'`` when there's a custom state).
115115
116116Lots of plumbing for errors.
117117
@@ -122,17 +122,17 @@ The string in the pair returned by elaborate is log information.
122122See JFP paper, but the names don't necessarily map to each other. The
123123paper is the "idealized version" without logging, additional state, etc.
124124
125−All the tactics take Raws, typechecking happens there.
125+All the tactics take ``Raw`` s, typechecking happens there.
126126
127−claim (x : t) assumes a new x : t.
127+``claim (x : t)`` assumes a new ``x : t``.
128128
129129PLEASE TIDY THINGS UP!
130130
131−proofSearch flag to try' is whether the failure came from a human (so
131+``proofSearch`` flag is to try whether the failure came from a human (so
132132fail) or from a machine (so continue)
133133
134−Idris-level syntax for providing alternatives explicitly: (\| x, y, z
135−\|) try x, y, z in order, and take the first that succeeds.
134+Idris-level syntax for providing alternatives explicitly: ``(| x, y, z
135+|)`` try ``x``, ``y``, ``z`` in order, and take the first that succeeds.
136136
137137Core/ProofState.hs
138138==================
@@ -140,37 +140,40 @@ Core/ProofState.hs
140140Core/Unify.hs
141141=============
142142
143−Deals with unification. Unification can reply with: - this works - this
144−can never work - this will work if these other unification problems work
145−out (eg unifying f x with 1)
143+Deals with unification. Unification can reply with:
146144
147−match\_unify: same thing as unification except it's just matching name
148−against name, term against term. x + y matches to 0 + y with x = 0. Used
149−for <== syntax as well as type class resolution.
145+- this works
146+- this can never work
147+- this will work if these other unification problems work out (e.g.
148+ unifying ``f x`` with ``1``)
149+
150+``match_unify``: same thing as unification except it's just matching name
151+against name, term against term. ``x + y`` matches to ``0 + y`` with
152+``x = 0``. Used for ``<==`` syntax as well as type class resolution.
150153
151154Idris/AbsSyntaxTree.hs
152155======================
153156
154−PTerm is the datatype of Idris syntax. P is for Program. Each PTerm
155−turns into a TT term by applying a series of tactics.
157+``PTerm`` is the datatype of Idris syntax. ``P`` is for *Program*.
158+Each ``PTerm`` turns into a TT term by applying a series of tactics.
156159
157−IState is the major interpreter state. The global context is the
158−tt\_ctxt field.
160+``IState`` is the major interpreter state. The global context is the
161+``tt_ctxt`` field.
159162
160−Ctxt maps possibly ambiguous names to their referents.
163+``Ctxt`` maps possibly ambiguous names to their referents.
161164
162165Idris/ElabDecls.hs
163166==================
164167
165−This is where the actual elaboration from PTerm to TT happens.
168+This is where the actual elaboration from ``PTerm`` to ``TT`` happens.
166169
167170Idris/ElabTerm.hs
168171=================
169172
170−build is the function that creates a Raw. All the "junk" is to deal with
173+``build`` is the function that creates a ``Raw``. All the "junk" is to deal with
171174things like metavars and so forth. It has to remember what names are
172175still to be defined, and it doesn't yet know the type (filled in by
173176unificaiton later). Also case expressions have to turn into top-level
174177functions.
175178
176−resolveTC is type class resolution.
179+``resolveTC`` is type class resolution.
docs/reference/uniqueness-types.rst+1−1
@@ -199,7 +199,7 @@ return it in exactly the condition in which it was received!
199199The restriction is that when a ``Borrowed`` type is matched, any
200200pattern variables under the ``Read`` which have a unique type may not
201201be referred to at all on the right hand side (unless they are
202−themselves ``lent`` to another function).
202+themselves lent to another function).
203203
204204Uniqueness information is stored in the type, and in particular in
205205function types. Once we're in a unique context, any new function which