on 1cdc9dd help sign in
Idris-dev/docs/tutorial/starting.rst
90 lines 3.2 kB history raw
1.. _sect-starting:
3***************
4Getting Started
5***************
7Prerequisites
8=============
10Before installing Idris, you will need to make sure you have all
11of the necessary libraries and tools. You will need:
13- A fairly recent Haskell platform. Version ``2013.2.0.0`` should be sufficiently recent, though it is better to be completely up to date.
15- The *GNU Multiple Precision Arithmetic Library* (GMP) is available from MacPorts/Homebrew and all major Linux distributions.
17Downloading and Installing
18==========================
20The easiest way to install Idris, if you have all of the
21prerequisites, is to type:
23::
25 cabal update; cabal install idris
27This will install the latest version released on Hackage, along with
28any dependencies. If, however, you would like the most up to date
29development version you can find it, as well as build instructions, on
30GitHub at: https://github.com/idris-lang/Idris-dev.
32If you haven't previously installed anything using Cabal, then Idris
33may not be on your path. Should the Idris executable not be found
34please ensure that you have added ``~/.cabal/bin`` to your ``$PATH``
35environment variable. Mac OS X users may find they need to add
36``~/Library/Haskell/bin`` instead, and Windows users will typically
37find that Cabal installs programs in ``%HOME%\AppData\Roaming\cabal\bin``.
39To check that installation has succeeded, and to write your first
40Idris program, create a file called ``hello.idr`` containing the
41following text:
43.. code-block:: idris
45 module Main
47 main : IO ()
48 main = putStrLn "Hello world"
50If you are familiar with Haskell, it should be fairly clear what the
51program is doing and how it works, but if not, we will explain the
52details later. You can compile the program to an executable by
53entering ``idris hello.idr -o hello`` at the shell prompt. This will
54create an executable called ``hello``, which you can run:
56::
58 $ idris hello.idr -o hello
59 $ ./hello
60 Hello world
62Please note that the dollar sign ``$`` indicates the shell prompt!
63Some useful options to the Idris command are:
65- ``-o prog`` to compile to an executable called ``prog``.
67- ``--check`` type check the file and its dependencies without starting the interactive environment.
69- ``--help`` display usage summary and command line options.
71The Interactive Environment
72===========================
74Entering ``idris`` at the shell prompt starts up the interactive
75environment. You should see something like the following:
77.. literalinclude:: ../listing/idris-prompt-start.txt
79This gives a ``ghci`` style interface which allows evaluation of, as
80well as type checking of, expressions; theorem proving, compilation;
81editing; and various other operations. The command ``:?`` gives a list
82of supported commands. Below, we see an example run in
83which ``hello.idr`` is loaded, the type of ``main`` is checked and
84then the program is compiled to the executable ``hello``. Type
85checking a file, if successful, creates a bytecode version of the file
86(in this case ``hello.ibc``) to speed up loading in future. The
87bytecode is regenerated if the source file changes.
89.. _run1:
90.. literalinclude:: ../listing/idris-prompt-helloworld.txt