2020-05-20 13:23:04 +03:00
|
|
|
.. _sect-starting:
|
|
|
|
|
|
|
|
***************
|
|
|
|
Getting Started
|
|
|
|
***************
|
|
|
|
|
2020-06-17 02:36:26 +03:00
|
|
|
Installing from Source
|
|
|
|
======================
|
|
|
|
|
2021-08-12 18:55:03 +03:00
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
windows
|
|
|
|
|
2020-05-20 13:23:04 +03:00
|
|
|
Prerequisites
|
2020-06-17 02:36:26 +03:00
|
|
|
-------------
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
Idris 2 is implemented in Idris 2 itself, so to bootstrap it you can build from
|
|
|
|
generated Scheme sources. To do this, you need either Chez Scheme (default, and
|
|
|
|
currently preferred since it is the fastest) or Racket. You can get one of
|
|
|
|
these from:
|
2020-05-20 13:23:04 +03:00
|
|
|
|
|
|
|
- `Chez Scheme <https://cisco.github.io/ChezScheme/>`_
|
2020-05-20 21:09:26 +03:00
|
|
|
- `Racket <https://download.racket-lang.org/>`_
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
Both are also available from MacPorts/Homebrew and all major Linux
|
2021-08-11 13:31:43 +03:00
|
|
|
distributions. Windows requires some further prerequisites, see :ref:`windows-install`.
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
**Note**: If you install Chez Scheme from source files, building it locally, make sure
|
2020-05-20 13:23:04 +03:00
|
|
|
you run ``./configure --threads`` to build multithreading support in.
|
|
|
|
|
|
|
|
Downloading and Installing
|
2020-06-17 02:36:26 +03:00
|
|
|
--------------------------
|
2020-05-20 13:23:04 +03:00
|
|
|
|
|
|
|
You can download the Idris 2 source from the `Idris web site
|
2020-05-20 21:09:26 +03:00
|
|
|
<https://www.idris-lang.org/pages/download.html>`_ or get the latest
|
|
|
|
development version from `idris-lang/Idris2
|
|
|
|
<https://github.com/idris-lang/Idris2>`_ on Github. This includes the Idris 2
|
2020-05-25 03:02:07 +03:00
|
|
|
source code and the Scheme code generated from that. Once you have
|
2020-05-20 21:09:26 +03:00
|
|
|
unpacked the source, you can install it as follows::
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
make bootstrap SCHEME=chez
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
Where `chez` is the executable name of the Chez Scheme compiler. This will
|
2020-05-25 03:02:07 +03:00
|
|
|
vary from system to system, but is often one of ``scheme``, ``chezscheme``, or
|
|
|
|
``chezscheme9.5``. If you are building via Racket, you can install it as
|
2020-05-20 21:09:26 +03:00
|
|
|
follows::
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-20 21:09:26 +03:00
|
|
|
make bootstrap-racket
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-05-26 05:32:33 +03:00
|
|
|
Once you've successfully bootstrapped with any of the above commands, you can
|
|
|
|
install with the command ``make install``. This will, by default, install into
|
|
|
|
``${HOME}/.idris2``. You can change this by editing the options in
|
|
|
|
``config.mk``. For example, to install into ``/usr/local``, you can edit the
|
2022-03-09 02:21:07 +03:00
|
|
|
``IDRIS2_PREFIX`` as follows::
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2022-03-09 02:21:07 +03:00
|
|
|
IDRIS2_PREFIX ?= /usr/local
|
2020-05-20 13:23:04 +03:00
|
|
|
|
2020-06-17 02:36:26 +03:00
|
|
|
Installing from a Package Manager
|
|
|
|
=================================
|
|
|
|
|
|
|
|
Installing Using Homebrew
|
2021-02-04 19:36:03 +03:00
|
|
|
-------------------------
|
2020-06-17 02:36:26 +03:00
|
|
|
|
|
|
|
If you are Homebrew user you can install Idris 2 together with all the requirements
|
2020-06-22 07:24:04 +03:00
|
|
|
by running following command::
|
2020-06-17 02:36:26 +03:00
|
|
|
|
|
|
|
brew install idris2
|
|
|
|
|
2024-01-21 15:28:35 +03:00
|
|
|
Installing Using Yay
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
If you are an Arch based distro user, you can install Idris 2 together with all the requirements
|
|
|
|
by running following command::
|
|
|
|
|
|
|
|
yay -S idris2
|
|
|
|
|
2020-06-17 02:36:26 +03:00
|
|
|
Checking Installation
|
|
|
|
=====================
|
|
|
|
|
2020-05-20 13:23:04 +03:00
|
|
|
To check that installation has succeeded, and to write your first
|
|
|
|
Idris program, create a file called ``hello.idr`` containing the
|
|
|
|
following text:
|
|
|
|
|
|
|
|
.. code-block:: idris
|
|
|
|
|
|
|
|
module Main
|
|
|
|
|
|
|
|
main : IO ()
|
|
|
|
main = putStrLn "Hello world"
|
|
|
|
|
|
|
|
If you are familiar with Haskell, it should be fairly clear what the
|
|
|
|
program is doing and how it works, but if not, we will explain the
|
|
|
|
details later. You can compile the program to an executable by
|
|
|
|
entering ``idris2 hello.idr -o hello`` at the shell prompt. This will,
|
|
|
|
by default, create an executable called ``hello``, which invokes a generated
|
2021-08-12 18:55:03 +03:00
|
|
|
and compiled Chez Scheme program, in the destination directory ``build/exec``
|
2020-05-20 13:23:04 +03:00
|
|
|
which you can run:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ idris2 hello.idr -o hello
|
2020-06-30 15:44:36 +03:00
|
|
|
$ ./build/exec/hello
|
2020-05-20 13:23:04 +03:00
|
|
|
Hello world
|
2021-01-22 16:30:42 +03:00
|
|
|
|
2020-05-20 13:23:04 +03:00
|
|
|
Please note that the dollar sign ``$`` indicates the shell prompt!
|
|
|
|
Some useful options to the Idris command are:
|
|
|
|
|
|
|
|
- ``-o prog`` to compile to an executable called ``prog``.
|
|
|
|
|
|
|
|
- ``--check`` type check the file and its dependencies without starting the interactive environment.
|
|
|
|
|
|
|
|
- ``--package pkg`` add package as dependency, e.g. ``--package contrib`` to make use of the contrib package.
|
|
|
|
|
|
|
|
- ``--help`` display usage summary and command line options.
|
|
|
|
|
|
|
|
You can find out more about compiling to executables in
|
|
|
|
Section :ref:`sect-execs`.
|
|
|
|
|
|
|
|
The Interactive Environment
|
|
|
|
===========================
|
|
|
|
|
|
|
|
Entering ``idris2`` at the shell prompt starts up the interactive
|
|
|
|
environment. You should see something like the following:
|
|
|
|
|
|
|
|
.. literalinclude:: ../listing/idris-prompt-start.txt
|
|
|
|
|
|
|
|
This gives a ``ghci`` style interface which allows evaluation of, as
|
|
|
|
well as type checking of, expressions; theorem proving, compilation;
|
|
|
|
editing; and various other operations. The command ``:?`` gives a list
|
|
|
|
of supported commands. Below, we see an example run in
|
|
|
|
which ``hello.idr`` is loaded, the type of ``main`` is checked and
|
|
|
|
then the program is compiled to the executable file ``hello``,
|
|
|
|
available in the destination directory ``build/exec/``. Type
|
|
|
|
checking a file, if successful, creates a bytecode version of the file (in this
|
|
|
|
case ``build/ttc/hello.ttc``) to speed up loading in future. The bytecode is
|
|
|
|
regenerated if the source file changes.
|
|
|
|
|
|
|
|
.. _run1:
|
|
|
|
.. literalinclude:: ../listing/idris-prompt-helloworld.txt
|