on master help sign in
Merge remote-tracking branch 'refs/remotes/upstream/master' into issue/2322

Conflicts: src/Idris/Delaborate.hs test/error004/expected

commit02a8a087f0ac832c2f6fec23743ce7ea621f322f authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateWed 3 Jun 2015, 13:09 (11 years ago) parent38123a4fe4c09d
66 files changed+2254−200
CHANGELOG+4−2 CONTRIBUTORS+1 docs/conf.py+2−2 docs/faq/faq.rst+3−3 docs/guides/index.rst+1 docs/guides/theorem-prover.rst+217 docs/index.rst+8−1 docs/reference/compilation.rst+61 docs/reference/elaborator-reflection.rst+143 docs/reference/ide-protocol.rst+2−2 docs/reference/index.rst+11 docs/reference/language-extensions.rst+36 docs/reference/language-features.rst+54 docs/reference/misc.rst+205 docs/reference/repl.rst+530 docs/reference/semantic-highlighting.rst+50 docs/reference/syntax-guide.rst+275 docs/reference/tactics.rst+213 docs/tutorial/typesfuns.rst+37−1 idris-tutorial.pdf idris.cabal+6−6 libs/base/Data/HVect.idr+4−4 libs/base/System/Interactive.idr+73 libs/base/base.ipkg+1−1 libs/effects/Effects.idr+2−4 libs/prelude/Language/Reflection.idr+10−8 libs/prelude/Language/Reflection/Elab.idr+22−4 libs/prelude/Prelude/Basics.idr+2−2 src/Idris/Core/Binary.hs+2 src/Idris/Core/CaseTree.hs+2 src/Idris/Core/DeepSeq.hs+8−1 src/Idris/Core/Elaborate.hs+13−3 src/Idris/Core/Evaluate.hs+36−32 src/Idris/Core/TT.hs+50−1 src/Idris/Coverage.hs+3−1 src/Idris/DeepSeq.hs−6 src/Idris/Delaborate.hs+12−10 src/Idris/Elab/Clause.hs+8−4 src/Idris/Elab/Term.hs+52−27 src/Idris/ElabDecls.hs+3−1 src/Idris/IBC.hs+1−1 src/Idris/Interactive.hs+1−1 src/Idris/Parser.hs+16−7 src/Idris/Prover.hs+10−7 src/Idris/Reflection.hs+8 test/basic006/expected+2−2 test/basic009/expected+1−1 test/error003/expected+1−2 test/error004/expected+7−7 test/error005/expected+10−10 test/meta002/expected+1−1 test/proof002/expected+2−2 test/proof007/expected+2−2 test/quasiquote003/expected+1−1 test/quasiquote004/expected+1−1 test/quasiquote006/expected+3−3 test/reg003/expected+3−3 test/reg007/expected+1−1 test/reg010/expected+1−1 test/reg023/expected+1−1 test/reg034/expected+2−2 test/reg044/expected+1−1 test/reg049/expected+2−2 test/reg054/expected+6−6 test/reg055/expected+5−5 test/tutorial006/expected+3−4
CHANGELOG+4−2
@@ -1,5 +1,7 @@
11New in 0.9.19:
22--------------
3+* The Idris Reference manual has been fleshed out with content originally found
4+ on the GitHub wiki.
35* The Show class has been moved into Prelude.Show and augmented with the method
46 showPrec, which allows correct parenthesization of showed terms. This comes
57 with the type Prec of precedences and a few helper functions.
@@ -19,8 +21,8 @@ New in 0.9.18:
1921 tested sufficiently, and lack a maintainer)
2022 + Float has been renamed 'Double' (Float is defined in the Prelude for
2123 compatibility)
22− + Externally defined primitives and operations now supported with
23− '%extern' directive, allowing back ends to define their own special
24+ + Externally defined primitives and operations now supported with
25+ '%extern' directive, allowing back ends to define their own special
2426 purpose primitives
2527 + Ptr and ManagedPtr have been removed and replaced with external primitives
2628* Add %hint function annotation, which allows functions to be used as
CONTRIBUTORS+1
@@ -33,6 +33,7 @@ Adam Sandberg Eriksson
3333Seo Sanghyeon
3434Benjamin Saunders
3535Alexander Shabalin
36+Timo Petteri Sinnemäki
3637JP Smith
3738startling
3839Chetan T
docs/conf.py+2−2
@@ -59,9 +59,9 @@ author = u'The Idris Community'
5959# built documents.
6060#
6161# The short X.Y version.
62−version = '0.9.17'
62+version = '0.9.18'
6363# The full version, including alpha/beta/rc tags.
64−release = '0.9.17'
64+release = '0.9.18'
6565
6666# The language for content autogenerated by Sphinx. Refer to documentation
6767# for a list of supported languages.
docs/faq/faq.rst+3−3
@@ -108,7 +108,7 @@ the undecidability of the `Halting Problem
108108to identify some programs which are definitely terminating. Idris does this
109109using "size change termination" which looks for recursive paths from a
110110function back to itself. On such a path, there must be at least one
111−argument which converges to a base case.
111+argument which converges to a base case.
112112
113113- Mutually recursive functions are supported
114114- However, all functions on the path must be fully applied. In particular,
@@ -166,8 +166,8 @@ where the Idris libs reside relative to the idris executable. The
166166IDRIS_TOOLCHAIN_DIR environment variable is optional, if that is set,
167167Idris will use that path to find the C compiler.
168168
169−Example:
170−.. code-block::
169+Example::
170+
171171 IDRIS_LIB_DIR="./libs" IDRIS_TOOLCHAIN_DIR="./mingw/bin" CABALFLAGS="-fffi -ffreestanding -frelease" make
172172
173173What does the name ‘Idris’ mean?
docs/guides/index.rst+1
@@ -19,3 +19,4 @@ Tutorials submitted by community members.
1919 :maxdepth: 1
2020
2121 type-providers-ffi
22+ theorem-prover
docs/guides/theorem-prover.rstnew file+217
@@ -0,0 +1,217 @@
1+*******************************
2+The Interactive Theorem Prover
3+*******************************
4+
5+This short guide contributed by a community member illustrates how to prove associativity of addition on ``Nat`` using the interactive theorem prover.
6+
7+First we define a module ``Foo.idr``
8+
9+.. code-block:: idris
10+
11+ module Foo
12+
13+ plusAssoc : plus n (plus m o) = plus (plus n m) o
14+ plusAssoc = ?rhs
15+
16+We wish to perform induction on ``n``. First we load the file into the Idris ``REPL`` as follows::
17+
18+ $ idris Foo.idr
19+
20+We will be given the following prompt, in future releases the version string will differ::
21+
22+ ____ __ _
23+ / _/___/ /____(_)____
24+ / // __ / ___/ / ___/ Version 0.9.18.1
25+ _/ // /_/ / / / (__ ) http://www.idris-lang.org/
26+ /___/\__,_/_/ /_/____/ Type :? for help
27+
28+ Idris is free software with ABSOLUTELY NO WARRANTY.
29+ For details type :warranty.
30+ Type checking ./Foo.idr
31+ Metavariables: Foo.rhs
32+ *Foo>
33+
34+
35+Explore the Context
36+====================
37+
38+We start the interactive session by asking Idris to prove the
39+metavaraible ``rhs`` using the command ``:p rhs``. Idris by default
40+will show us the initial context. This looks as follows::
41+
42+ *Foo> :p rhs
43+ ---------- Goal: ----------
44+ { hole 0 }:
45+ (n : Nat) ->
46+ (m : Nat) ->
47+ (o : Nat) ->
48+ plus n (plus m o) = plus (plus n m) o
49+
50+Application of Intros
51+=====================
52+
53+We first apply the ``intros`` tactic::
54+
55+ -Foo.rhs> intros
56+ ---------- Other goals: ----------
57+ { hole 2 }
58+ { hole 1 }
59+ { hole 0 }
60+ ---------- Assumptions: ----------
61+ n : Nat
62+ m : Nat
63+ o : Nat
64+ ---------- Goal: ----------
65+ { hole 3 }:
66+ plus n (plus m o) = plus (plus n m) o
67+
68+Induction on ``n``
69+==================
70+
71+Then apply ``induction`` on to ``n``::
72+
73+ -Foo.rhs> induction n
74+ ---------- Other goals: ----------
75+ elim_S0
76+ { hole 2 }
77+ { hole 1 }
78+ { hole 0 }
79+ ---------- Assumptions: ----------
80+ n : Nat
81+ m : Nat
82+ o : Nat
83+ ---------- Goal: ----------
84+ elim_Z0:
85+ plus Z (plus m o) = plus (plus Z m) o
86+
87+
88+Compute
89+=======
90+
91+::
92+
93+ -Foo.rhs> compute
94+ ---------- Other goals: ----------
95+ elim_S0
96+ { hole 2 }
97+ { hole 1 }
98+ { hole 0 }
99+ ---------- Assumptions: ----------
100+ n : Nat
101+ m : Nat
102+ o : Nat
103+ ---------- Goal: ----------
104+ elim_Z0:
105+ plus m o = plus m o
106+
107+Trivial
108+=======
109+
110+::
111+
112+ -Foo.rhs> trivial
113+ ---------- Other goals: ----------
114+ { hole 2 }
115+ { hole 1 }
116+ { hole 0 }
117+ ---------- Assumptions: ----------
118+ n : Nat
119+ m : Nat
120+ o : Nat
121+ ---------- Goal: ----------
122+ elim_S0:
123+ (n__0 : Nat) ->
124+ (plus n__0 (plus m o) = plus (plus n__0 m) o) ->
125+ plus (S n__0) (plus m o) = plus (plus (S n__0) m) o
126+
127+Intros
128+======
129+
130+::
131+
132+ -Foo.rhs> intros
133+ ---------- Other goals: ----------
134+ { hole 4 }
135+ elim_S0
136+ { hole 2 }
137+ { hole 1 }
138+ { hole 0 }
139+ ---------- Assumptions: ----------
140+ n : Nat
141+ m : Nat
142+ o : Nat
143+ n__0 : Nat
144+ ihn__0 : plus n__0 (plus m o) = plus (plus n__0 m) o
145+ ---------- Goal: ----------
146+ { hole 5 }:
147+ plus (S n__0) (plus m o) = plus (plus (S n__0) m) o
148+
149+
150+Compute
151+=======
152+
153+::
154+
155+ -Foo.rhs> compute
156+ ---------- Other goals: ----------
157+ { hole 4 }
158+ elim_S0
159+ { hole 2 }
160+ { hole 1 }
161+ { hole 0 }
162+ ---------- Assumptions: ----------
163+ n : Nat
164+ m : Nat
165+ o : Nat
166+ n__0 : Nat
167+ ihn__0 : plus n__0 (plus m o) = plus (plus n__0 m) o
168+ ---------- Goal: ----------
169+ { hole 5 }:
170+ S (plus n__0 (plus m o)) = S (plus (plus n__0 m) o)
171+
172+
173+Rewrite
174+=======
175+
176+::
177+
178+ -Foo.rhs> rewrite ihn__0
179+ ---------- Other goals: ----------
180+ { hole 5 }
181+ { hole 4 }
182+ elim_S0
183+ { hole 2 }
184+ { hole 1 }
185+ { hole 0 }
186+ ---------- Assumptions: ----------
187+ n : Nat
188+ m : Nat
189+ o : Nat
190+ n__0 : Nat
191+ ihn__0 : plus n__0 (plus m o) = plus (plus n__0 m) o
192+ ---------- Goal: ----------
193+ { hole 6 }:
194+ S (plus n__0 (plus m o)) = S (plus n__0 (plus m o))
195+
196+Trivial
197+=======
198+
199+::
200+
201+ -Foo.rhs> trivial
202+ rhs: No more goals.
203+ -Foo.rhs> qed
204+ Proof completed!
205+ Foo.rhs = proof
206+ intros
207+ induction n
208+ compute
209+ trivial
210+ intros
211+ compute
212+ rewrite ihn__0
213+ trivial
214+
215+Two goals were created: one for ``Z`` and one for ``S``.
216+Here we have proven associativity, and assembled a tactic based proof script.
217+This proof script can be added to ``Foo.idr``.
docs/index.rst+8−1
@@ -105,6 +105,13 @@ Language Reference
105105 reference/ffi
106106 reference/erasure
107107 reference/ide-protocol
108+ reference/semantic-highlighting
109+ reference/repl
110+ reference/tactics
111+ reference/compilation
112+ reference/language-features
113+ reference/language-extensions
114+ reference/misc
108115
109116.. _guides:
110117
@@ -116,4 +123,4 @@ Short Guides
116123 :maxdepth: 1
117124
118125 guides/type-providers-ffi
119−
126+ guides/theorem-prover
docs/reference/compilation.rstnew file+61
@@ -0,0 +1,61 @@
1+***********************
2+Compilation and Logging
3+***********************
4+
5+
6+This section provides highlights of the Idris compilation process, and
7+provides details over how you can follow the process through logging.
8+
9+Compilation Process
10+===================
11+
12+Idris follows the following compilation process:
13+
14+#. Parsing
15+#. Type Checking
16+
17+ #. Elaboration
18+ #. Coverage
19+ #. Unification
20+ #. Totality Checking
21+ #. Erasure
22+
23+#. Code Generation
24+
25+ #. Defunctionalisation
26+ #. Inlining
27+ #. Resolving variables
28+ #. Code Generation
29+
30+
31+Type Checking Only
32+==================
33+
34+With Idris you can ask it to terminate the compilation process after type checking has completed. This is achieved through use of either:
35+
36++ The command line options
37+
38+ + ``--check`` for files
39+ + ``--checkpkg`` for packages
40+
41++ The REPL command: ``:check``
42+
43+Use of this option will still result in the generation of the Idris binary ``.ibc`` files, and is suitable if you do not wish to generate code from one of the supported backends.
44+
45+Logging Output
46+==============
47+
48+Logging of the Idris output can be used to diagnose problems with the compilation of your program.
49+Idris supports the logging at various different levels of verbosity: 1 to 10.
50+
51++ Level 0: Show no logging output. Default level
52++ Level 1: High level details of the compilation process.
53++ Level 2: Provides details of the coverage checking, and further details the elaboration process specifically: Class, Clauses, Data, Term, and Types,
54++ Level 3: Provides details of compilation of the IRTS, erasue, parsing, case splitting, and further details elaboration of: Instances, Providers, and Values.
55++ Level 4: Provides further details on: Erasure, Coverage Checking, Case splitting, and elaboration of clauses.
56++ Level 5: Provides details on the prover, and further details elaboration (adding declarations) and compilation of the IRTS.
57++ Level 6: Further details elaboration and coverage checking.
58++ Level 7:
59++ Level 8:
60++ Level 9:
61++ Level 10: Further details elaboration.
docs/reference/elaborator-reflection.rstnew file+143
@@ -0,0 +1,143 @@
1+*********************
2+Elaborator Reflection
3+*********************
4+
5+The Idris elaborator is responsible for converting high-level Idris code into the core language.
6+It is implemented as a kind of embedded tactic language in Haskell, where tactic scripts are written in an *elaboration monad* that provides error handling and a proof state.
7+For details, see Edwin Brady's 2013 paper in the Journal of Functional Programming.
8+
9+Elaborator reflection makes the elaboration type as well as a selection of its tactics available to Idris code.
10+This means that metaprograms written in Idris can have complete control over the elaboration process, generating arbitrary code, and they have access to all of the facilities available in the elaborator, such as higher-order unification, type checking, and emitting auxiliary definitions.
11+
12+WARNING
13+=======
14+
15+Elaborator reflection is a new, **experimental** feature. It **will change**. You've been warned.
16+
17+The Elaborator State
18+====================
19+
20+The elaborator state contains information about the ongoing elaboration process.
21+In particular, it contains a *goal type*, which is to be filled by an under-construction *proof term*.
22+The proof term can contain *holes*, each of which has a scope in which it is valid and a type.
23+Some holes may additionally contain *guesses*, which can be substituted in the scope of the hole.
24+The holes are tracked in a *hole queue*, and one of them is *focused*.
25+In addition to the goal type, proof term, and holes, the elaborator state contains a collection of unsolved unification problems that can affect elaboration.
26+
27+The elaborator state is not directly available to Idris programs.
28+Instead, it is modified through the use of *tactics*, which are operations that affect the elaborator state.
29+A tactic that returns a value of type ``a``, potentially modifying the elaborator state, has type ``Elab a``.
30+The default tactics are all in the namespace ``Language.Reflection.Elab.Tactics``.
31+
32+
33+Running Elaborator Scripts
34+==========================
35+
36+On their own, tactics have no effect.
37+The meta-operation ``%runElab script`` runs ``script`` in the current elaboration context.
38+For example, the following script constructs the identity function at type ``Nat``:
39+
40+.. code-block:: idris
41+ idNat : Nat -> Nat
42+ idNat = %runElab (do intro (Just (UN "x"))
43+ fill (Var (UN "x"))
44+ solve)
45+
46+On the right-hand side, the Idris elaborator has the goal ``Nat -> Nat``.
47+When it encounters the ``%runElab`` directive, it fulfills this goal by running the provided script.
48+The first tactic, ``intro``, constructs a lambda that binds the name ``x``.
49+The name argument is optional because a default name can be taken from the function type.
50+Now, the proof term is of the form ``\x : Nat => {hole}``.
51+The second tactic, ``fill``, fills this hole with a guess, giving the term ``\x : Nat => {hole≈x}``.
52+Finally, the ``solve`` tactic instantiates the guess, giving the result ``\x : Nat => x``.
53+
54+Because elaborator scripts are ordinary Idris expressions, it is also possible to use them in multiple contexts.
55+Note that there is nothing ``Nat``-specific about the above script.
56+We can generate identity functions at any concrete type using the same script:
57+
58+.. code-block:: idris
59+ mkId : Elab ()
60+ mkId = do intro (Just (UN "x"))
61+ fill (Var (UN "x"))
62+ solve
63+
64+ idNat : Nat -> Nat
65+ idNat = %runElab mkId
66+
67+ idUnit : () -> ()
68+ idUnit = %runElab mkId
69+
70+ idString : String -> String
71+ idString = %runElab mkId
72+
73+
74+Failure
75+=======
76+
77+Some tactics may *fail*.
78+For example, ``intro`` will fail if the focused hole does not have a function type, ``solve`` will fail if the current hole does not contain a guess, and ``fill`` will fail if the term to be filled in has the wrong type.
79+Scripts can also fail explicitly using the ``fail`` tactic.
80+
81+To account for failure, there is an ``Alternative`` instance for ``Elab``.
82+The ``<|>`` operator first tries the script to its left.
83+If that script fails, any changes that it made to the state are undone and the right argument is executed.
84+If the first argument succeeds, then the second argument is not executed.
85+
86+Querying the Elaboration State
87+==============================
88+
89+``Elab`` includes operations to query the elaboration state, allowing scripts to use information about their environment to steer the elaboration process.
90+The ordinary Idris bind syntax can be used to propagate this information.
91+For example, a tactic that solves the current goal when it is the unit type might look like this:
92+
93+.. code-block:: idris
94+ triv : Elab ()
95+ triv = do compute
96+ g <- getGoal
97+ case (snd g) of
98+ `(() : Type) => do fill `(() : ())
99+ solve
100+ otherGoal => fail [ TermPart otherGoal
101+ , TextPart "is not trivial"
102+ ]
103+
104+The tactic ``compute`` normalises the type of its goal with respect to the current context.
105+While not strictly necessary, this allows ``triv`` to be used in contexts where the triviality of the goal is not immediately apparent.
106+Then, ``getGoal`` is used, and its result is bound to ``g``.
107+Because it returns a pair consisting of the current goal's name and type, we case-split on its second projection.
108+If the goal type turns out to have been the unit type, we fill using the unit constructor and solve the goal.
109+Otherwise, we fail with an error message informing the user that the current goal is not trivial.
110+
111+Additionally, the elaboration state can be dumped into an error message with the ``debug`` tactic.
112+A variant, ``debugMessage``, allows arbitrary messages to be included with the state, allowing for a kind of "``printf`` debuggging" of elaboration scripts.
113+The message format used by ``debugMessage`` is the same for errors produced by the error reflection mechanism, allowing the re-use of the Idris pretty-printer when rendering messages.
114+
115+Changing the Global Context
116+===========================
117+
118+``Elab`` scripts can modify the global context during execution.
119+Just as the Idris elaborator produces auxiliary definitions to implement features such as ``where``-blocks and ``case`` expressions, user elaboration scripts may need to define functions.
120+Furthermore, this allows ``Elab`` reflection to be used to implement features such as type class deriving.
121+The operations ``declareType``, ``defineFunction``, and ``addInstance`` allow ``Elab`` scripts to modify the global context.
122+
123+Using Idris's Features
124+======================
125+
126+The Idris compiler has a number of ways to automate the construction of terms.
127+On its own, the ``Elab`` state and its interactions with the unifier allow implicits to be solved using unification.
128+Additional operations use further features of Idris.
129+In particular, ``resolveTC`` solves the current goal using type class resolution, ``search`` invokes the proof search mechanism, and ``sourceLocation`` finds the context in the original file at which the elaboration script is invoked.
130+
131+
132+Recursive Elaboration
133+=====================
134+
135+The elaboration mechanism can be invoked recursively using the ``runElab`` tactic.
136+This tactic takes a goal type and an elaboration script as arguments and runs the script in a fresh lexical evironment to create an inhabitant of the provided goal type.
137+This is primarily useful for code generation, particularly for generating pattern-matching clauses, where variable scope needs to be one that isn't the present local context.
138+
139+Learn More
140+==========
141+While this documentation is still incomplete, elaboration reflection works in Idris today.
142+As you wait for the completion of the documentation, the list of built-in tactics can be obtained using the ``:browse`` command in an Idris REPL or the corresponding feature in one of the graphical IDE clients to explore the ``Language.Reflection.Elab.Tactics`` namespace.
143+All of the built-in tactics contain documentation strings.
docs/reference/ide-protocol.rst+2−2
@@ -27,7 +27,7 @@ An example interaction from loading the file ``/home/hannes/empty.idr`` looks as
2727
2828The first message is the request from idris-mode to load the specific file, which length is hex 2a, decimal 42 (including the newline at the end).
2929The request identifier is set to 1.
30−The first message from Idris is to write the string ``Type checking /home/hannes/empty.idr'', another is to set the prompt to ``*/home/hannes/empty''.
30+The first message from Idris is to write the string ``Type checking /home/hannes/empty.idr``, another is to set the prompt to ``*/home/hannes/empty``.
3131The answer, starting with ``:return`` is ``ok``, and additional information is that the file was loaded.
3232
3333There are three atoms in the wire language: numbers, strings, and symbols.
@@ -188,4 +188,4 @@ They have the format:::
188188
189189 (:output (:ok (:highlight-source POSNS)))
190190
191−where ``POSNS``is a list of positions to highlight. Each of these is a two-element list whose first element is a position (encoded as for the ``source-loc`` property above) and whose second element is highlighting metadata in the same format used for output.
191+where ``POSNS`` is a list of positions to highlight. Each of these is a two-element list whose first element is a position (encoded as for the ``source-loc`` property above) and whose second element is highlighting metadata in the same format used for output.
docs/reference/index.rst+11
@@ -24,3 +24,14 @@ This will tell you how Idris works, for using it you should read the Idris Tutor
2424 uniqueness-types
2525 ffi
2626 erasure
27+ semantic-highlighting
28+ repl
29+ syntax-guide
30+ tactics
31+ compilation
32+ language-features
33+ language-extensions
34+ elaborator-reflection
35+ misc
36+
37+
docs/reference/language-extensions.rstnew file+36
@@ -0,0 +1,36 @@
1+*******************
2+Language Extensions
3+*******************
4+
5+
6+
7+Type Providers
8+===============
9+
10+Idris type providers are a way to get the type system to reflect
11+observations about the world outside of Idris. Similarly to `F# type
12+providers <http://msdn.microsoft.com/en-us/library/vstudio/hh156509.aspx>`__,
13+they cause effectful computations to run during type checking, returning
14+information that the type checker can use when checking the rest of the
15+program. While F# type providers are based on code generation, Idris
16+type providers use only the ordinary execution semantics of Idris to
17+generate the information.
18+
19+A type provider is simply a term of type ``IO (Provider t)``, where
20+``Provider`` is a data type with constructors for a successful result
21+and an error. The type ``t`` can be either ``Type`` (the type of types)
22+or a concrete type. Then, a type provider ``p`` is invoked using the
23+syntax ``%provide (x : t) with p``. When the type checker encounters
24+this line, the IO action ``p`` is executed. Then, the resulting term is
25+extracted from the IO monad. If it is ``Provide y`` for some ``y : t``,
26+then ``x`` is bound to ``y`` for the remainder of typechecking and in
27+the compiled code. If execution fails, a generic error is reported and
28+type checking terminates. If the resulting term is ``Error e`` for some
29+string ``e``, then type checking fails and the error ``e`` is reported
30+to the user.
31+
32+Example Idris type providers can be seen at `this
33+repository <https://github.com/david-christiansen/idris-type-providers>`__.
34+More detailed descriptions are available in David Christiansen's `WGP
35+'13 paper <http://dx.doi.org/10.1145/2502488.2502495>`__ and `M.Sc.
36+thesis <http://itu.dk/people/drc/david-christiansen-thesis.pdf>`__.
docs/reference/language-features.rstnew file+54
@@ -0,0 +1,54 @@
1+**********************
2+Core Language Features
3+**********************
4+
5+
6+- Full-spectrum dependent types
7+- Strict evaluation (plus ``Lazy : Type -> Type`` type constructor for
8+ explicit laziness)
9+- Lambda, Pi (forall), Let bindings
10+- Pattern matching definitions
11+- Export modifiers ``public``, ``abstract``, ``private``
12+- Function options ``partial``, ``total``
13+- ``where`` clauses
14+- "magic with"
15+- Implicit arguments (in top level types)
16+- "Bound" implicit arguments ``{n : Nat} -> {a : Type} -> Vect n a``
17+- "Unbound" implicit arguments --- ``Vect n a`` is equivalent to the
18+ above in a type, ``n`` and ``a`` are implicitly bound. This applies
19+ to names beginning with a lower case letter in an argument position.
20+- 'Tactic' implicit arguments, which are solved by running a tactic
21+ script or giving a default argument, rather than by unification.
22+- Unit type ``()``, empty type ``Void``
23+- Tuples (desugaring to nested pairs)
24+- Dependent pair syntax ``(x : T ** P x)`` (there exists an ``x`` of
25+ type ``T`` such that ``P x``)
26+- Inline ``case`` expressions
27+- Heterogeneous equality
28+- ``do`` notation
29+- Idiom brackets
30+- Type classes, suppoting default methods and dependencies between
31+ methods
32+- ``rewrite`` prf ``in`` expr
33+- Metavariables
34+- Inline proof/tactic scripts
35+- Implicit coercion
36+- ``codata``
37+- Also ``Inf : Type -> Type`` type constructor for mixed data/codata.
38+ In fact ``codata`` is implemented by putting recusive arguments under
39+ ``Inf``.
40+- ``syntax`` rules for defining pattern and term syntactic sugar
41+- these are used in the standard library to define
42+ ``if ... then ... else`` expressions and an Agda-style preorder
43+ reasoning syntax.
44+- `Uniqueness
45+ typing <https://github.com/idris-lang/Idris-dev/wiki/Uniqueness-Types>`__
46+ using the ``UniqueType`` universe.
47+- `Partial
48+ evaluation <https://github.com/idris-lang/Idris-dev/wiki/Static-Arguments-and-Partial-Evaluation>`__
49+ by ``[static]`` argument annotations.
50+- Error message reflection
51+- Eliminators
52+- Label types ``'name``
53+- ``%logging n``
54+- ``%unifyLog``
docs/reference/misc.rstnew file+205
@@ -0,0 +1,205 @@
1+**************
2+Miscellaneous
3+**************
4+
5+Things we have yet to classify, or are two small to justify their own page.
6+
7+
8+The Unifier Log
9+===============
10+
11+If you're having a hard time debugging why the unifier won't accept
12+something (often while debugging the compiler itself), try applying the
13+special operator ``%unifyLog`` to the expression in question. This will
14+cause the type checker to spit out all sorts of informative messages.
15+
16+
17+Namespaces and type-directed disambiguation
18+===========================================
19+
20+Names can be defined in separate namespaces, and disambiguated by type.
21+An expression ``with NAME EXPR`` will privilege the namespace ``NAME``
22+in the expression ``EXPR``. For example:
23+
24+::
25+
26+ Idris> with List [[1,2],[3,4],[5,6]]
27+ [[1, 2], [3, 4], [5, 6]] : List (List Integer)
28+
29+ Idris> with Vect [[1,2],[3,4],[5,6]]
30+ [[1, 2], [3, 4], [5, 6]] : Vect 3 (Vect 2 Integer)
31+
32+ Idris> [[1,2],[3,4],[5,6]]
33+ Can't disambiguate name: Prelude.List.::, Prelude.Stream.::, Prelude.Vect.::
34+
35+
36+Alternatives
37+============
38+
39+The syntax ``(| option1, option2, option3, ... |)`` type checks each
40+of the options in turn until one of them works. This is used, for
41+example, when translating integer literals.
42+
43+::
44+
45+ Idris> the Nat (| "foo", Z, (-3) |)
46+ 0 : Nat
47+
48+
49+This can also be used to give simple automated proofs, for example: trying
50+some constructors of proofs.
51+
52+::
53+
54+ syntax Trivial = (| oh, refl |)
55+
56+
57+Totality checking assertions
58+============================
59+
60+All definitions are checked for *coverage* (i.e. all well-typed
61+applications are handled) and either for *termination* (i.e. all
62+well-typed applications will eventually produce an answer) or, if
63+returning codata, for productivity (in practice, all recursive calls are
64+constructor guarded).
65+
66+Obviously, termination checking is undecidable. In practice, the
67+termination checker looks for *size change* - every cycle of recursive
68+calls must have a decreasing argument, such as a recursive argument of a
69+strictly positive data type.
70+
71+There are two built-in functions which can be used to give the totality
72+checker a hint:
73+
74+- ``assert_total x`` asserts that the expression ``x`` is terminating
75+ and covering, even if the totality checker cannot tell. This can be
76+ used for example if ``x`` uses a function which does not cover all
77+ inputs, but the caller knows that the specific input is covered.
78+- ``assert_smaller p x`` asserts that the expression ``x`` is
79+ structurally smaller than the pattern ``p``.
80+
81+For example, the following function is not checked as total:
82+
83+::
84+
85+ qsort : Ord a => List a -> List a
86+ qsort [] = []
87+ qsort (x :: xs) = qsort (filter (<= x) xs) ++ (x :: qsort (filter (>= x) xs)))
88+
89+This is because the checker cannot tell that ``filter`` will always
90+produce a value smaller than the pattern ``x :: xs`` for the recursive
91+call to ``qsort``. We can assert that this will always be true as
92+follows:
93+
94+::
95+
96+ total
97+ qsort : Ord a => List a -> List a
98+ qsort [] = []
99+ qsort (x :: xs) = qsort (assert_smaller (x :: xs) (filter (<= x) xs)) ++
100+ (x :: qsort (assert_smaller (x :: xs) (filter (>= x) xs))))
101+
102+
103+Preorder reasoning
104+==================
105+
106+This syntax is defined in the module ``Syntax.PreorderReasoning`` in the
107+``base`` package. It provides a syntax for composing proofs of
108+reflexive-transitive relations, using overloadable functions called
109+``step`` and ``qed``. This module also defines ``step`` and ``qed``
110+functions allowing the syntax to be used for demonstrating equality.
111+Here is an example:
112+
113+.. code:: idris
114+
115+ import Syntax.PreorderReasoning
116+ multThree : (a, b, c : Nat) -> a * b * c = c * a * b
117+ multThree a b c =
118+ (a * b * c) ={ sym (multAssociative a b c) }=
119+ (a * (b * c)) ={ cong (multCommutative b c) }=
120+ (a * (c * b)) ={ multAssociative a c b }=
121+ (a * c * b) ={ cong {f = (*b)} (multCommutative a c) }=
122+ (c * a * b) QED
123+
124+Note that the parentheses are required -- only a simple expression can
125+be on the left of ``={ }=`` or ``QED``. Also, when using preorder
126+reasoning syntax to prove things about equality, remember that you can
127+only relate the entire expression, not subexpressions. This might
128+occasionally require the use of ``cong``.
129+
130+Finally, although equality is the most obvious application of preorder
131+reasoning, it can be used for any reflexive-transitive relation.
132+Something like ``step1 ={ just1 }= step2 ={ just2 }= end QED`` is
133+translated to ``(step step1 just1 (step step2 just2 (qed end)))``,
134+selecting the appropriate definitions of ``step`` and ``qed`` through
135+the normal disambiguation process. The standard library, for example,
136+also contains an implementation of preorder reasoning on isomorphisms.
137+
138+
139+Pattern matching on Implicit Arguments
140+======================================
141+
142+Pattern matching is only allowed on implicit arguments when they are
143+referred by name, e.g.
144+
145+.. code:: idris
146+
147+ foo : {n : Nat} -> Nat
148+ foo {n = Z} = Z
149+ foo {n = S k} = k
150+
151+or
152+
153+.. code:: idris
154+
155+ foo : {n : Nat} -> Nat
156+ foo {n = n} = n
157+
158+The latter could be shortened to the following:
159+
160+.. code:: idris
161+
162+ foo : {n : Nat} -> Nat
163+ foo {n} = n
164+
165+That is, ``{x}`` behaves like ``{x=x}``.
166+
167+
168+Existence of an instance
169+========================
170+
171+In order to show that an instance of some typeclass is defined for some
172+type, one could use the ``%instance`` keyword:
173+
174+.. code:: idris
175+
176+ foo : Num Nat
177+ foo = %instance
178+
179+'match' application
180+===================
181+
182+``ty <== name`` applies the function ``name`` in such a way that it has
183+the type ``ty``, by matching ``ty`` against the function's type. This
184+can be used in proofs, for example:
185+
186+::
187+
188+ plus_comm : (n : Nat) -> (m : Nat) -> (n + m = m + n)
189+ -- Base case
190+ (Z + m = m + Z) <== plus_comm =
191+ rewrite ((m + Z = m) <== plusZeroRightNeutral) ==>
192+ (Z + m = m) in refl
193+
194+ -- Step case
195+ (S k + m = m + S k) <== plus_comm =
196+ rewrite ((k + m = m + k) <== plus_comm) in
197+ rewrite ((S (m + k) = m + S k) <== plusSuccRightSucc) in
198+ refl
199+
200+Reflection
201+==========
202+
203+Including ``%reflection`` functions and ``quoteGoal x by fn in t``,
204+which applies ``fn`` to the expected type of the current expression, and
205+puts the result in ``x`` which is in scope when elaborating ``t``.
docs/reference/repl.rstnew file+530
@@ -0,0 +1,530 @@
1+.. _sect-repl:
2+
3+**************
4+The Idris REPL
5+**************
6+
7+Idris comes with a ``REPL``.
8+
9+Evaluation
10+==========
11+
12+Being a fully dependently typed language, Idris has two phases where it
13+evaluates things, compile-time and run-time. At compile-time it will only
14+evaluate things which it knows to be total (i.e. terminating and covering all
15+possible inputs) in order to keep type checking decidable. The compile-time
16+evaluator is part of the Idris kernel, and is implemented in Haskell using a
17+HOAS (higher order abstract syntax) style representation of values. Since
18+everything is known to have a normal form here, the evaluation strategy doesn't
19+actually matter because either way it will get the same answer, and in practice
20+it will do whatever the Haskell run-time system chooses to do.
21+
22+The REPL, for convenience, uses the compile-time notion of evaluation. As well
23+as being easier to implement (because we have the evaluator available) this can
24+be very useful to show how terms evaluate in the type checker. So you can see
25+the difference between:
26+
27+.. code-block:: idris
28+
29+ Idris> \n, m => (S n) + m
30+ \n => \m => S (plus n m) : Nat -> Nat -> Nat
31+
32+ Idris> \n, m => n + (S m)
33+ \n => \m => plus n (S m) : Nat -> Nat -> Nat
34+
35+Customisation
36+=============
37+
38+Idris supports initialisation scripts.
39+
40+Initialisation scripts
41+~~~~~~~~~~~~~~~~~~~~~~
42+
43+When the Idris REPL starts up, it will attempt to open the file
44+repl/init in Idris's application data directory. The application data
45+directory is the result of the Haskell function call
46+``getAppUserDataDirectory "idris"``, which on most Unix-like systems
47+will return $HOME/.idris and on various versions of Windows will return
48+paths such as ``C:/Documents And Settings/user/Application Data/appName``.
49+
50+The file repl/init is a newline-separate list of REPL commands. Not all
51+commands are supported in initialisation scripts — only the subset that
52+will not interfere with the normal operation of the REPL. In particular,
53+setting colours, display options such as showing implicits, and log
54+levels are supported.
55+
56+Example initialisation script
57+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+::
59+
60+ :colour prompt white italic bold
61+ :colour implicit magenta italic
62+
63+
64+
65+The ``REPL`` Commands
66+=====================
67+
68+The current set of supported commands are:
69+
70++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
71+|Command | Arguments | Purpose |
72++================+==============================+==========================================================================================================+
73+|<expr> | | Evaluate an expression |
74++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
75+|:t :type | <expr> | Check the type of an expression |
76++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
77+|:core | <expr> | View the core language representation of a term |
78++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
79+|:miss :missing | <name> | Show missing clauses |
80++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
81+|:doc | <name> | Show internal documentation |
82++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
83+|:mkdoc | <namespace> | Generate IdrisDoc for namespace(s) and dependencies |
84++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
85+|:apropos | [<package list>] <name> | Search names, types, and documentation |
86++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
87+|:s :search | [<package list>] <expr> | Search for values by type |
88++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
89+|:wc :whocalls | <name> | List the callers of some name |
90++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
91+|:cw :callswho | <name> | List the callees of some name |
92++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
93+|:browse | <namespace> | List the contents of some namespace |
94++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
95+|:total | <name> | Check the totality of a name |
96++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
97+|:r :reload | | Reload current file |
98++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
99+|:l :load | <filename> | Load a new file |
100++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
101+|:cd | <filename> | Change working directory |
102++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
103+|:module | <module> | Import an extra module |
104++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
105+|:e :edit | | Edit current file using $EDITOR or $VISUAL |
106++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
107+|:m :metavars | | Show remaining proof obligations (metavariables) |
108++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
109+|:p :prove | <metavar> | Prove a metavariable |
110++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
111+|:a :addproof | <name> | Add proof to source file |
112++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
113+|:rmproof | <name> | Remove proof from proof stack |
114++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
115+|:showproof | <name> | Show proof |
116++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
117+|:proofs | | Show available proofs |
118++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
119+|:x | <expr> | Execute IO actions resulting from an expression using the interpreter |
120++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
121+|:c :compile | <filename> | Compile to an executable [codegen] <filename> |
122++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
123+|:exec :execute | [<expr>] | Compile to an executable and run |
124++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
125+|:dynamic | <filename> | Dynamically load a C library (similar to %dynamic) |
126++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
127+|:dynamic | | List dynamically loaded C libraries |
128++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
129+|:? :h :help | | Display this help text |
130++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
131+|:set | <option> | Set an option (errorcontext, showimplicits) |
132++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
133+|:unset | <option> | Unset an option |
134++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
135+|:color :colour | <option> | Turn REPL colours on or off; set a specific colour |
136++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
137+|:consolewidth | auto|infinite|<number> | Set the width of the console |
138++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
139+|:q :quit | | Exit the Idris system |
140++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
141+|:w :warranty | | Displays warranty information |
142++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
143+|:let | (<top-level-declaration>)... | Evaluate a declaration, such as a function definition, instance implementation, or fixity declaration |
144++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
145+|:unlet :undefine|(<name>)... | Remove the listed repl definitions, or all repl definitions if no names given |
146++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
147+|:printdef | <name> | Show the definition of a function |
148++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
149+|:pp :pprint | <option> <number> <name> | Pretty prints an Idris function in either LaTeX or HTML and for a specified width. |
150++----------------+------------------------------+----------------------------------------------------------------------------------------------------------+
151+
152+
153+Using the REPL
154+==============
155+
156+
157+Getting help
158+~~~~~~~~~~~~
159+
160+The command ``:help`` (or ``:h`` or ``:?``) prints a short summary of
161+the available commands.
162+
163+Quitting Idris
164+~~~~~~~~~~~~~~
165+
166+If you would like to leave Idris, simply use ``:q`` or ``:quit``.
167+
168+Evaluating expressions
169+~~~~~~~~~~~~~~~~~~~~~~
170+
171+To evaluate an expression, simply type it. If Idris is unable to infer
172+the type, it can be helpful to use the operator ``the`` to manually
173+provide one, as Idris's syntax does not allow for direct type
174+annotations. Examples of ``the`` include:
175+
176+::
177+
178+ Idris> the Nat 4
179+ 4 : Nat
180+ Idris> the Int 4
181+ 4 : Int
182+ Idris> the (List Nat) [1,2]
183+ [1,2] : List Nat
184+ Idris> the (Vect _ Nat) [1,2]
185+ [1,2] : Vect 2 Nat
186+
187+This may not work in cases where the expression still involves ambiguous
188+names. The name can be disambiguated by using the ``with`` keyword:
189+
190+::
191+
192+ Idris> sum [1,2,3]
193+ When elaborating an application of function Prelude.Foldable.sum:
194+ Can't disambiguate name: Prelude.List.::,
195+ Prelude.Stream.::,
196+ Prelude.Vect.::
197+ Idris> with List sum [1,2,3]
198+ 6 : Integer
199+
200+Adding let bindings
201+~~~~~~~~~~~~~~~~~~~
202+
203+To add a let binding to the REPL, use ``:let``. It's likely you'll also
204+need to provide a type annotation. ``:let`` also works for other
205+declarations as well, such as ``data``.
206+
207+::
208+
209+ Idris> :let x : String; x = "hello"
210+ Idris> x
211+ "hello" : String
212+ Idris> :let data Foo : Type where Bar : Foo
213+ Idris> Bar
214+ Bar : Foo
215+
216+Getting type information
217+~~~~~~~~~~~~~~~~~~~~~~~~
218+
219+To ask Idris for the type of some expression, use the ``:t`` command.
220+Additionally, if used with an overloaded name, Idris will provide all
221+overloadings and their types. To ask for the type of an infix operator,
222+surround it in parentheses.
223+
224+::
225+
226+ Idris> :t "foo"
227+ "foo" : String
228+ Idris> :t plus
229+ Prelude.Nat.plus : Nat -> Nat -> Nat
230+ Idris> :t (++)
231+ Builtins.++ : String -> String -> String
232+ Prelude.List.++ : (List a) -> (List a) -> List a
233+ Prelude.Vect.++ : (Vect m a) -> (Vect n a) -> Vect (m + n) a
234+ Idris> :t plus 4
235+ plus (Builtins.fromInteger 4) : Nat -> Nat
236+
237+You can also ask for basic information about typeclasses with ``:doc``:
238+
239+::
240+
241+ Idris> :doc Monad
242+ Type class Monad
243+
244+ Parameters:
245+ m
246+
247+ Methods:
248+ (>>=) : Monad m => m a -> (a -> m b) -> m b
249+
250+ infixl 5
251+
252+ Instances:
253+ Monad id
254+ Monad PrimIO
255+ Monad IO
256+ Monad Maybe
257+
258+ ...
259+
260+Other documentation is also available from ``:doc``:
261+
262+::
263+
264+ Idris> :doc (+)
265+ Prelude.Classes.+ : (a : Type) -> (Num a) -> a -> a -> a
266+
267+ infixl 8
268+
269+ Arguments:
270+ Class constraint Prelude.Classes.Num a
271+ __pi_arg : a
272+ __pi_arg1 : a
273+
274+::
275+
276+ Idris> :doc Vect
277+ Data type Prelude.Vect.Vect : Nat -> Type -> Type
278+
279+ Arguments:
280+ Nat
281+ Type
282+
283+ Constructors:
284+
285+ Prelude.Vect.Nil : (a : Type) -> Vect 0 a
286+
287+
288+ Prelude.Vect.:: : (a : Type) -> (n : Nat) -> a -> (Vect n a) -> Vect (S n) a
289+
290+ infixr 7
291+
292+ Arguments:
293+ a
294+ Vect n a
295+
296+::
297+
298+ Idris> :doc Monad
299+ Type class Prelude.Monad.Monad
300+ Methods:
301+
302+ Prelude.Monad.>>= : (m : Type -> Type) -> (a : Type) -> (b : Type) -> (Monad m) -> (m a) -> (a -> m b) -> m b
303+
304+ infixl 5
305+
306+ Arguments:
307+ Class constraint Prelude.Monad.Monad m
308+ __pi_arg : m a
309+ __pi_arg1 : a -> m b
310+
311+Finding things
312+~~~~~~~~~~~~~~
313+
314+The command ``:apropos`` searches names, types, and documentation for
315+some string, and prints the results. For example:
316+
317+::
318+
319+ Idris> :apropos eq
320+ eqPtr : Ptr -> Ptr -> IO Bool
321+
322+
323+ eqSucc : (left : Nat) -> (right : Nat) -> (left = right) -> S left = S right
324+ S preserves equality
325+
326+ lemma_both_neq : ((x = x') -> _|_) -> ((y = y') -> _|_) -> ((x, y) = (x', y')) -> _|_
327+
328+
329+ lemma_fst_neq_snd_eq : ((x = x') -> _|_) -> (y = y') -> ((x, y) = (x', y)) -> _|_
330+
331+
332+ lemma_snd_neq : (x = x) -> ((y = y') -> _|_) -> ((x, y) = (x, y')) -> _|_
333+
334+
335+ lemma_x_eq_xs_neq : (x = y) -> ((xs = ys) -> _|_) -> (x :: xs = y :: ys) -> _|_
336+
337+
338+ lemma_x_neq_xs_eq : ((x = y) -> _|_) -> (xs = ys) -> (x :: xs = y :: ys) -> _|_
339+
340+
341+ lemma_x_neq_xs_neq : ((x = y) -> _|_) -> ((xs = ys) -> _|_) -> (x :: xs = y :: ys) -> _|_
342+
343+
344+ prim__eqB16 : Bits16 -> Bits16 -> Int
345+
346+ prim__eqB16x8 : Bits16x8 -> Bits16x8 -> Bits16x8
347+
348+ prim__eqB32 : Bits32 -> Bits32 -> Int
349+
350+ prim__eqB32x4 : Bits32x4 -> Bits32x4 -> Bits32x4
351+
352+ prim__eqB64 : Bits64 -> Bits64 -> Int
353+
354+ prim__eqB64x2 : Bits64x2 -> Bits64x2 -> Bits64x2
355+
356+ prim__eqB8 : Bits8 -> Bits8 -> Int
357+
358+ prim__eqB8x16 : Bits8x16 -> Bits8x16 -> Bits8x16
359+
360+ prim__eqBigInt : Integer -> Integer -> Int
361+
362+ prim__eqChar : Char -> Char -> Int
363+
364+ prim__eqFloat : Float -> Float -> Int
365+
366+ prim__eqInt : Int -> Int -> Int
367+
368+ prim__eqString : String -> String -> Int
369+
370+ prim__syntactic_eq : (a : Type) -> (b : Type) -> (x : a) -> (y : b) -> Maybe (x = y)
371+
372+ sequence : Traversable t => Applicative f => (t (f a)) -> f (t a)
373+
374+
375+ sequence_ : Foldable t => Applicative f => (t (f a)) -> f ()
376+
377+
378+ Eq : Type -> Type
379+ The Eq class defines inequality and equality.
380+
381+ GTE : Nat -> Nat -> Type
382+ Greater than or equal to
383+
384+ LTE : Nat -> Nat -> Type
385+ Proofs that n is less than or equal to m
386+
387+ gte : Nat -> Nat -> Bool
388+ Boolean test than one Nat is greater than or equal to another
389+
390+ lte : Nat -> Nat -> Bool
391+ Boolean test than one Nat is less than or equal to another
392+
393+ ord : Char -> Int
394+ Convert the number to its ASCII equivalent.
395+
396+ replace : (x = y) -> (P x) -> P y
397+ Perform substitution in a term according to some equality.
398+
399+ sym : (l = r) -> r = l
400+ Symmetry of propositional equality
401+
402+ trans : (a = b) -> (b = c) -> a = c
403+ Transitivity of propositional equality
404+
405+``:search`` does a type-based search, in the spirit of Hoogle. See `Type-directed search (:search) <https://github.com/idris-lang/Idris-dev/wiki/Type-directed-search-%28%3Asearch%29>`_ for more details. Here is an example:
406+
407+::
408+
409+ Idris> :search a -> b -> a
410+ = Prelude.Basics.const : a -> b -> a
411+ Constant function. Ignores its second argument.
412+
413+ = assert_smaller : a -> b -> b
414+ Assert to the totality checker than y is always structurally
415+ smaller than x (which is typically a pattern argument)
416+
417+ > malloc : Int -> a -> a
418+
419+
420+ > Prelude.pow : Num a => a -> Nat -> a
421+
422+
423+ > Prelude.Classes.(*) : Num a => a -> a -> a
424+
425+
426+ > Prelude.Classes.(+) : Num a => a -> a -> a
427+ ... (More results)
428+
429+``:search`` can also look for dependent types:
430+
431+::
432+
433+ Idris> :search plus (S n) n = plus n (S n)
434+ < Prelude.Nat.plusSuccRightSucc : (left : Nat) ->
435+ (right : Nat) ->
436+ S (left + right) = left + S right
437+
438+Loading and reloading Idris code
439+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440+
441+The command ``:l File.idr`` will load File.idr into the
442+currently-running REPL, and ``:r`` will reload the last file that was
443+loaded.
444+
445+Totality
446+~~~~~~~~
447+
448+All Idris definitions are checked for totality. The command
449+``:total <NAME>`` will display the result of that check. If a definition
450+is not total, this may be due to an incomplete pattern match. If that is
451+the case, ``:missing`` or ``:miss`` will display the missing cases.
452+
453+Editing files
454+~~~~~~~~~~~~~
455+
456+The command ``:e`` launches your default editor on the current module.
457+After control returns to Idris, the file is reloaded.
458+
459+Invoking the compiler
460+~~~~~~~~~~~~~~~~~~~~~
461+
462+The current module can be compiled to an executable using the command
463+``:c <FILENAME>`` or ``:compile <FILENAME>``. This command allows to
464+specify codegen, so for example JavaScript can be generated using
465+``:c javascript <FILENAME>``. The ``:exec`` command will compile the
466+program to a temporary file and run the resulting executable.
467+
468+IO actions
469+~~~~~~~~~~
470+
471+Unlike GHCI, the Idris REPL is not inside of an implicit IO monad. This
472+means that a special command must be used to execute IO actions.
473+``:x tm`` will execute the IO action ``tm`` in an Idris interpreter.
474+
475+Dynamically loading C libraries
476+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
477+
478+Sometimes, an Idris program will depend on external libraries written in
479+C. In order to use these libraries from the Idris interpreter, they must
480+first be dynamically loaded. This is achieved through the
481+``%dynamic <LIB>`` directive in Idris source files or through the
482+``:dynamic <LIB>`` command at the REPL. The current set of dynamically
483+loaded libraries can be viewed by executing ``:dynamic`` with no
484+arguments. These libraries are available through the Idris FFI in `type
485+providers <#type-providers>`__ and ``:exec``.
486+
487+Colours
488+=======
489+
490+Idris terms are available in amazing colour! By default, the Idris REPL
491+uses colour to distinguish between data constructors, types or type
492+constructors, operators, bound variables, and implicit arguments. This
493+feature is available on all POSIX-like systems, and there are plans to
494+allow it to work on Windows as well.
495+
496+If you do not like the default colours, they can be turned off using the
497+command
498+
499+::
500+
501+ :colour off
502+
503+and, when boredom strikes, they can be re-enabled using the command
504+
505+::
506+
507+ :colour on
508+
509+To modify a colour, use the command
510+
511+::
512+
513+ :colour <CATEGORY> <OPTIONS>
514+
515+where ``<CATEGORY`` is one of ``keyword``, ``boundvar``, ``implicit``,
516+``function``, ``type``, ``data``, or ``prompt``, and is a
517+space-separated list drawn from the colours and the font options. The
518+available colours are ``default``, ``black``, ``yellow``, ``cyan``,
519+``red``, ``blue``, ``white``, ``green``, and ``magenta``. If more than
520+one colour is specified, the last one takes precedence. The available
521+options are ``dull`` and ``vivid``, ``bold`` and ``nobold``, ``italic``
522+and ``noitalic``, ``underline`` and ``nounderline``, forming pairs of
523+opposites. The colour ``default`` refers to your terminal's default
524+colour.
525+
526+The colours used at startup can be changed using REPL initialisation
527+scripts.
528+
529+Colour can be disabled at startup by the ``--nocolour`` command-line
530+option.
docs/reference/semantic-highlighting.rstnew file+50
@@ -0,0 +1,50 @@
1+****************************************
2+Semantic Highlighting & Pretty Printing
3+****************************************
4+
5+Since ``v0.9.18`` Idris comes with support for semantic highlighting.
6+When using the ``REPL`` or IDE support, Idris will highlight your code accordingly to its meaning within the Idris structure. A precursor to semantic highlighting support is the pretty printing of definitions to console, LaTeX, or HTML.
7+
8+The default styling scheme used was inspired by Conor McBride's own set of stylings, informally known as *Conor Colours*.
9+
10+
11+Legend
12+======
13+
14+The concepts and their default stylings are as follows:
15+
16++----------------+---------------+----------------+----------------+
17+| Idris Term | HTML | LaTeX | IDE/REPL |
18++================+===============+================+================+
19+| Bound Variable | Purple | Magenta | |
20++----------------+---------------+----------------+----------------+
21+| Keyword | Bold | Underlined | |
22++----------------+---------------+----------------+----------------+
23+| Function | Green | Green | |
24++----------------+---------------+----------------+----------------+
25+| Type | Blue | Blue | |
26++----------------+---------------+----------------+----------------+
27+| Data | Red | Red | |
28++----------------+---------------+----------------+----------------+
29+| Implicit | Italic Purple | Italic Magenta | |
30++----------------+---------------+----------------+----------------+
31+
32+Pretty Printing
33+===============
34+
35+Idris also supports the pretty printing of code to HTML and LaTeX using the commands:
36+
37++ ``:pp <latex|html> <width> <function name>``
38++ ``:pprint <latex|html> <width> <function name>``
39+
40+
41+Customisation
42+=============
43+
44+If you are not happy with the colours used, the VIM and Emacs editor support allows for customisation of the colours. When pretty printing Idris code as LaTeX and HTML, commands and a CSS style are provided. The colours used by the REPL can be customised through the initialisation script.
45+
46+
47+Further Information
48+===================
49+
50+Please also see the `Idris Extras <https://github.com/idris-hackers/idris-extras>`_ project for links to editor support, and pre-made style files for LaTeX and HTML.
docs/reference/syntax-guide.rstnew file+275
@@ -0,0 +1,275 @@
1+**************
2+Syntax Guide
3+**************
4+
5+Examples are mostly adapted from the Idris tutorial.
6+
7+Variables
8+---------
9+
10+A variable is always defined by defining its type on one line, and its
11+value on the next line, using the syntax
12+
13+::
14+
15+ <id> : <type>
16+ <id> = <value>
17+
18+Examples
19+
20+.. code:: idris
21+
22+ x : Int
23+ x = 100
24+ hello : String
25+ hello = "hello"
26+
27+Types
28+-----
29+
30+In Idris, types are first class values. So a type declaration is the
31+same as just declaration of a variable whose type is ``Type``. In Idris,
32+variables that denote a type must being with a capital letter. Example:
33+
34+.. code:: idris
35+
36+ MyIntType : Type
37+ MyIntType = Int
38+
39+a more interesting example:
40+
41+.. code:: idris
42+
43+ MyListType : Type
44+ MyListType = List Int
45+
46+Data types
47+~~~~~~~~~~
48+
49+Idris provides two kinds of syntax for defining data types. The first,
50+Haskell style syntax, defines a regular algebraic data type. For example
51+
52+.. code:: idris
53+
54+ data Either a b = Left a | Right b
55+
56+or
57+
58+.. code:: idris
59+
60+ data List a = Nil | (::) a (List a)
61+
62+The second, more general kind of data type, is defined using Agda or
63+GADT style syntax. This syntax defines a data type that is parameterized
64+by some values (in the ``Vect`` exampe, a value of type ``Nat`` and a
65+value of type ``Type``).
66+
67+.. code:: idris
68+
69+ data Vect : Nat -> Type -> Type where
70+ Nil : Vect Z a
71+ (::) : (x : a) -> (xs : Vect n a) -> Vect (S n) a
72+
73+Operators
74+---------
75+
76+Arithmetic
77+~~~~~~~~~~
78+
79+::
80+
81+ x + y
82+ x - y
83+ x * y
84+ x / y
85+ (x * y) + (a / b)
86+
87+Equality and Relational
88+~~~~~~~~~~~~~~~~~~~~~~~
89+
90+::
91+
92+ x == y
93+ x /= y
94+ x >= y
95+ x > y
96+ x <= y
97+ x < y
98+
99+Conditional
100+~~~~~~~~~~~
101+
102+::
103+
104+ x && y
105+ x || y
106+ not x
107+
108+Conditionals
109+------------
110+
111+If Then Else
112+~~~~~~~~~~~~
113+
114+::
115+
116+ if <test> then <true> else <false>
117+
118+Case Expressions
119+~~~~~~~~~~~~~~~~
120+
121+::
122+
123+ case <test> of
124+ <case 1> => <expr>
125+ <case 2> => <expr>
126+ ...
127+ otherwise => <expr>
128+
129+Functions
130+---------
131+
132+Named
133+~~~~~
134+
135+Named functions are defined in the same way as variables, with the type
136+followed by the definition.
137+
138+::
139+
140+ <id> : <argument type> -> <return type>
141+ <id> arg = <expr>
142+
143+Example
144+
145+.. code:: idris
146+
147+ plusOne : Int -> Int
148+ plusOne x = x + 1
149+
150+Functions can also have multiple inputs, for example
151+
152+.. code:: idris
153+
154+ makeHello : String -> String -> String
155+ makeHello first last = "hello, my name is " ++ first ++ " " ++ last
156+
157+Functions can also have named arguments. This is required if you want to
158+annotate parameters in a docstring. The following shows the same
159+``makeHello`` function as above, but with named parameters which are
160+also annotated in the docstring
161+
162+.. code:: idris
163+
164+ ||| Makes a string introducing a person
165+ ||| @first The person's first name
166+ ||| @last The person's last name
167+ makeHello : (first : String) -> (last : String) -> String
168+ makeHello first last = "hello, my name is " ++ first ++ " " ++ last
169+
170+Like Haskell, Idris functions can be defined by pattern matching. For
171+example
172+
173+.. code:: idris
174+
175+ sum : List Int -> Int
176+ sum [] = 0
177+ sum (x :: xs) = x + (sum xs)
178+
179+Similarly case analysis looks like
180+
181+.. code:: idris
182+
183+ answerString : Bool -> String
184+ answerString False = "Wrong answer"
185+ answerString True = "Correct answer"
186+
187+Dependent Functions
188+~~~~~~~~~~~~~~~~~~~
189+
190+Dependent functions are functions where the type of the return value
191+depends on the input value. In order to define a dependent function,
192+named parameters must be used, since the parameter will appear in the
193+return type. For example, consider
194+
195+.. code:: idris
196+
197+ zeros : (n : Nat) -> Vect n Int
198+ zeros Z = []
199+ zeros (S k) = 0 :: (zeros k)
200+
201+In this example, the return type is ``Vect n Int`` which is an
202+expression which depends on the input parameter ``n``. ### Anonymous
203+Arguments in anonymous functions are separated by comma.
204+
205+::
206+
207+ (\x => <expr>)
208+ (\x, y => <expr>)
209+
210+Modifiers
211+~~~~~~~~~
212+
213+Visibility
214+^^^^^^^^^^
215+
216+::
217+
218+ public
219+ abstract
220+ private
221+
222+Totality
223+^^^^^^^^
224+
225+::
226+
227+ total
228+ implicit
229+ partial
230+ covering
231+
232+Options
233+^^^^^^^
234+
235+::
236+
237+ %export
238+ %hint
239+ %no_implicit
240+ %error_handler
241+ %error_reverse
242+ %assert_total
243+ %reflection
244+ %specialise [<name list>]
245+
246+Misc
247+----
248+
249+Comments
250+~~~~~~~~
251+
252+::
253+
254+ -- Single Line
255+ {- Multiline -}
256+ ||| Docstring (goes before definition)
257+
258+Directives
259+----------
260+
261+::
262+
263+ %lib <path>
264+ %link <path>
265+ %flag <path>
266+ %include <path>
267+ %hide <function>
268+ %freeze <name>
269+ %access <accessibility>
270+ %default <totality>
271+ %logging <level 0--11>
272+ %dynamic <list of libs>
273+ %name <list of names>
274+ %error_handlers <list of names>
275+ %language <extension>
docs/reference/tactics.rstnew file+213
@@ -0,0 +1,213 @@
1+***************************
2+Tactics and Theorem Proving
3+***************************
4+
5+Idris supports interactive theorem proving, and theh analyse of
6+context through metavariables. To list all unproven metavariables,
7+use the command ``:m``. This will display their qualified names and
8+the expected types. To interactively prove a metavariable, use the
9+command ``:p name`` where ``name`` is the metavariable. Once the proof
10+is complete, the command ``:a`` will append it to the current module.
11+
12+Once in the interactive prover, the following commands are available:
13+
14+Basic commands
15+==============
16+
17+- ``:q`` - Quits the prover (gives up on proving current lemma).
18+- ``abandon`` - Same as :q
19+- ``state`` - Displays the current state of the proof.
20+- ``term`` - Displays the current proof term complete with its
21+ yet-to-be-filled holes (is only really useful for debugging).
22+- ``undo`` - Undoes the last tactic.
23+- ``qed`` - Once the interactive theorem prover tells you "No more
24+ goals," you get to type this in celebration! (Completes the proof and
25+ exits the prover)
26+
27+Commonly Used Tactics
28+=====================
29+
30+Compute
31+-------
32+
33+- ``compute`` - Normalizes all terms in the goal (note: does not
34+ normalize assumptions)
35+
36+::
37+
38+ ---------- Goal: ----------
39+ (Vect (S (S Z + (S Z) + (S n))) Nat) -> Vect (S (S (S (S n)))) Nat
40+ -lemma> compute
41+ ---------- Goal: ----------
42+ (Vect (S (S (S (S n)))) Nat) -> Vect (S (S (S (S n)))) Nat
43+ -lemma>
44+
45+Exact
46+-----
47+
48+- ``exact`` - Provide a term of the goal type directly.
49+
50+::
51+
52+ ---------- Goal: ----------
53+ Nat
54+ -lemma> exact Z
55+ lemma: No more goals.
56+ -lemma>
57+
58+Refine
59+------
60+
61+- ``refine`` - Use a name to refine the goal. If the name needs
62+ arguments, introduce them as new goals.
63+
64+Trivial
65+-------
66+
67+- ``trivial`` - Satisfies the goal using an assumption that matches its
68+ type.
69+
70+::
71+
72+ ---------- Assumptions: ----------
73+ value : Nat
74+ ---------- Goal: ----------
75+ Nat
76+ -lemma> trivial
77+ lemma: No more goals.
78+ -lemma>
79+
80+Intro
81+-----
82+
83+- ``intro`` - If your goal is an arrow, turns the left term into an
84+ assumption.
85+
86+::
87+
88+ ---------- Goal: ----------
89+ Nat -> Nat -> Nat
90+ -lemma> intro
91+ ---------- Assumptions: ----------
92+ n : Nat
93+ ---------- Goal: ----------
94+ Nat -> Nat
95+ -lemma>
96+
97+You can also supply your own name for the assumption:
98+
99+::
100+
101+ ---------- Goal: ----------
102+ Nat -> Nat -> Nat
103+ -lemma> intro number
104+ ---------- Assumptions: ----------
105+ number : Nat
106+ ---------- Goal: ----------
107+ Nat -> Nat
108+
109+
110+Intros
111+------
112+
113+- ``intros`` - Exactly like intro, but it operates on all left terms at
114+ once.
115+
116+::
117+
118+ ---------- Goal: ----------
119+ Nat -> Nat -> Nat
120+ -lemma> intros
121+ ---------- Assumptions: ----------
122+ n : Nat
123+ m : Nat
124+ ---------- Goal: ----------
125+ Nat
126+ -lemma>
127+
128+let
129+---
130+
131+- ``let`` - Introduces a new assumption; you may use current
132+ assumptions to define the new one.
133+
134+::
135+
136+ ---------- Assumptions: ----------
137+ n : Nat
138+ ---------- Goal: ----------
139+ BigInt
140+ -lemma> let x = toIntegerNat n
141+ ---------- Assumptions: ----------
142+ n : Nat
143+ x = toIntegerNat n: BigInt
144+ ---------- Goal: ----------
145+ BigInt
146+ -lemma>
147+
148+rewrite
149+-------
150+
151+- ``rewrite`` - Takes an expression with an equality type (x = y), and
152+ replaces all instances of x in the goal with y. Is often useful in
153+ combination with 'sym'.
154+
155+::
156+
157+ ---------- Assumptions: ----------
158+ n : Nat
159+ a : Type
160+ value : Vect Z a
161+ ---------- Goal: ----------
162+ Vect (mult n Z) a
163+ -lemma> rewrite sym (multZeroRightZero n)
164+ ---------- Assumptions: ----------
165+ n : Nat
166+ a : Type
167+ value : Vect Z a
168+ ---------- Goal: ----------
169+ Vect Z a
170+ -lemma>
171+
172+induction
173+---------
174+
175+- ``induction`` - (``Note that this is still experimental`` and you may
176+ get strange results and error messages. We are aware of these and
177+ will finish the implementation eventually!) Prove the goal by
178+ induction. Each constructor of the datatype becomes a goal.
179+ Constructors with recursive arguments become induction steps, while
180+ simple constructors become base cases. Note that this only works for
181+ datatypes that have eliminators: a datatype definition must have the
182+ ``%elim`` modifier.
183+
184+
185+sourceLocation
186+--------------
187+
188+- ``sourceLocation`` - Solve the current goal with information about
189+ the location in the source code where the tactic was invoked. This is
190+ mostly for embedded DSLs and programmer tools like assertions that
191+ need to know where they are called. See
192+ ``Language.Reflection.SourceLocation`` for more information.
193+
194+Less commonly-used tactics
195+==========================
196+
197+- ``applyTactic`` - Apply a user-defined tactic. This should be a
198+ function of type ``List (TTName, Binder TT) -> TT -> Tactic``, where
199+ the first argument represents the proof context and the second
200+ represents the goal. If your tactic will produce a proof term
201+ directly, use the ``Exact`` constructor from ``Tactic``.
202+- ``attack`` - ?
203+- ``equiv`` - Replaces the goal with a new one that is convertible with
204+ the old one
205+- ``fill`` - ?
206+- ``focus`` - ?
207+- ``mrefine`` - Refining by matching against a type
208+- ``reflect`` - ?
209+- ``solve`` - Takes a guess with the correct type and fills a hole with
210+ it, closing a proof obligation. This happens automatically in the
211+ interactive prover, so ``solve`` is really only relevant in tactic
212+ scripts used for helping implicit argument resolution.
213+- ``try`` - ?
docs/tutorial/typesfuns.rst+37−1
@@ -246,10 +246,46 @@ So, for example, the following definitions are legal:
246246Dependent Types
247247===============
248248
249+First Class Types
250+-----------------
251+
252+In Idris, types are a first class language construct, meaning that they
253+can be computed and manipulated (and passed to functions) just like any
254+other language construct. For example, we could write a function which
255+computes a type:
256+
257+.. code-block:: idris
258+
259+ isSingleton : Bool -> Type
260+ isSingleton True = Nat
261+ isSingleton False = List Nat
262+
263+This function calculates the appropriate type from a ``Bool`` which flags
264+whether the type should be a singleton or not. We can use this function
265+to calculate a type anywhere that a type can be used. For example, it
266+can be used to calculate a return type:
267+
268+.. code-block:: idris
269+
270+ mkSingle : (x : Bool) -> isSingleton x
271+ mkSingle False = 0
272+ mkSingle True = []
273+
274+Or it can be used to have varying input types. The following function
275+calculates either the sum of a list of ``Nat``, or returns the given
276+``Nat``, depending on whether the singleton flag is true:
277+
278+.. code-block:: idris
279+
280+ sum : (single : Bool) -> isSingleton single -> Nat
281+ sum False x = x
282+ sum True [] = 0
283+ sum True (x :: xs) = x + sum True xs
284+
249285Vectors
250286-------
251287
252−A standard example of a dependent type is the type of “lists with
288+A standard example of a dependent data type is the type of “lists with
253289length”, conventionally called vectors in the dependent type
254290literature. They are available as part of the Idris library, by
255291importing ``Data.Vect``, or we can declare them as follows:
idris-tutorial.pdf

Binary file not shown.

idris.cabal+6−6
@@ -883,7 +883,7 @@ Library
883883 , filepath < 1.5
884884 , fingertree >= 0.1 && < 0.2
885885 , haskeline >= 0.7 && < 0.8
886− , lens >= 4.1.1 && < 4.10
886+ , lens >= 4.1.1 && < 4.12
887887 , mtl >= 2.1 && < 2.3
888888 , network < 2.7
889889 , optparse-applicative >= 0.11 && < 0.12
@@ -914,7 +914,7 @@ Library
914914 , TemplateHaskell
915915
916916 ghc-prof-options: -auto-all -caf-all
917− ghc-options: -threaded -rtsopts -O2
917+ ghc-options: -threaded -rtsopts
918918
919919 if os(linux)
920920 cpp-options: -DLINUX
@@ -958,7 +958,7 @@ Executable idris
958958 , transformers
959959
960960 ghc-prof-options: -auto-all -caf-all
961− ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
961+ ghc-options: -threaded -rtsopts -funbox-strict-fields
962962
963963Executable idris-c
964964 Main-is: Main.hs
@@ -971,7 +971,7 @@ Executable idris-c
971971 , transformers
972972
973973 ghc-prof-options: -auto-all -caf-all
974− ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
974+ ghc-options: -threaded -rtsopts -funbox-strict-fields
975975
976976Executable idris-javascript
977977 Main-is: Main.hs
@@ -984,7 +984,7 @@ Executable idris-javascript
984984 , transformers
985985
986986 ghc-prof-options: -auto-all -caf-all
987− ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
987+ ghc-options: -threaded -rtsopts -funbox-strict-fields
988988
989989Executable idris-node
990990 Main-is: Main.hs
@@ -997,4 +997,4 @@ Executable idris-node
997997 , transformers
998998
999999 ghc-prof-options: -auto-all -caf-all
1000− ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
1000+ ghc-options: -threaded -rtsopts -funbox-strict-fields
libs/base/Data/HVect.idr+4−4
@@ -1,7 +1,7 @@
11module Data.HVect
22
33import Data.Fin
4−import Data.Vect
4+import public Data.Vect
55
66%access public
77%default total
@@ -56,17 +56,17 @@ instance (Shows k ts) => Show (HVect ts) where
5656
5757||| Extract an arbitrary element of the correct type.
5858||| @ t the goal type
59−get : {default tactics { search 100; } p : Elem t ts} -> HVect ts -> t
59+get : {auto p : Elem t ts} -> HVect ts -> t
6060get {p = Here} (x::xs) = x
6161get {p = There p'} (x::xs) = get {p = p'} xs
6262
6363||| Replace an element with the correct type.
64−put : {default tactics { search 100; } p : Elem t ts} -> t -> HVect ts -> HVect ts
64+put : {auto p : Elem t ts} -> t -> HVect ts -> HVect ts
6565put {p = Here} y (x::xs) = y :: xs
6666put {p = There p'} y (x::xs) = x :: put {p = p'} y xs
6767
6868||| Update an element with the correct type.
69−update : {default tactics { search 100; } p : Elem t ts} -> (t -> u) -> HVect ts -> HVect (replaceByElem ts p u)
69+update : {auto p : Elem t ts} -> (t -> u) -> HVect ts -> HVect (replaceByElem ts p u)
7070update {p = Here} f (x::xs) = f x :: xs
7171update {p = There p'} f (x::xs) = x :: update {p = p'} f xs
7272
libs/base/System/Interactive.idrnew file+73
@@ -0,0 +1,73 @@
1+||| Various helper functions for creating simple interactive systems.
2+|||
3+||| These are mostly intended for helping with teaching, in that they will allow
4+||| the easy creation of interactive programs without needing to teach IO
5+||| or Effects first, but they also capture some common patterns of interactive
6+||| programming.
7+module System.Interactive
8+
9+{-
10+When the interfaces and names are stable, these are intended for the Prelude.
11+-}
12+
13+import System
14+
15+||| Process input from an open file handle, while maintaining a state.
16+||| @ state the input state
17+||| @ onRead the function to run on reading a line, returning a String to
18+||| output and a new state
19+||| @ onEOF the function to run on reaching end of file, returning a String
20+||| to output
21+public partial
22+processHandle : File ->
23+ (state : a) ->
24+ (onRead : a -> String -> (String, a)) ->
25+ (onEOF : a -> String) ->
26+ IO ()
27+processHandle h acc onRead onEOF
28+ = if !(feof h)
29+ then putStr (onEOF acc)
30+ else do x <- fread h
31+ let (out, acc') = onRead acc x
32+ putStr out
33+ processHandle h acc' onRead onEOF
34+
35+||| Process input from the standard input stream, while maintaining a state.
36+||| @ state the input state
37+||| @ onRead the function to run on reading a line, returning a String to
38+||| output and a new state
39+||| @ onEOI the function to run on reaching end of input, returning a String
40+||| to output
41+public partial
42+processStdin : (state : a) ->
43+ (onRead : a -> String -> (String, a)) ->
44+ (onEOI : a -> String) -> IO ()
45+processStdin = processHandle stdin
46+
47+||| A basic read-eval-print loop, maintaining a state
48+||| @ state the input state
49+||| @ prompt the prompt to show
50+||| @ onInput the function to run on reading input, returning a String to
51+||| output and a new state. Returns Nothing if the repl should exit
52+public partial
53+replWith : (state : a) -> (prompt : String) ->
54+ (onInput : a -> String -> Maybe (String, a)) -> IO a
55+replWith acc prompt fn
56+ = do putStr prompt
57+ x <- getLine
58+ case fn acc x of
59+ Just (out, acc') => do putStr out
60+ replWith acc' prompt fn
61+ Nothing => return acc
62+
63+||| A basic read-eval-print loop
64+||| @ prompt the prompt to show
65+||| @ onInput the function to run on reading input, returning a String to
66+||| output
67+public partial
68+repl : (prompt : String) ->
69+ (onInput : String -> String) -> IO ()
70+repl prompt fn
71+ = do replWith () prompt (\x, s => Just (fn s, ()))
72+ return ()
73+
libs/base/base.ipkg+1−1
@@ -5,7 +5,7 @@ modules = System,
55
66 Debug.Error, Debug.Trace,
77
8− System.Info,
8+ System.Info, System.Interactive,
99
1010 Language.Reflection.Utils,
1111
libs/effects/Effects.idr+2−4
@@ -293,15 +293,13 @@ syntax MkDefaultEnv = with Env
293293
294294call : {a, b: _} -> {e : Effect} ->
295295 (eff : e t a b) ->
296− {default tactics { search 100; }
297− prf : EffElem e a xs} ->
296+ {auto prf : EffElem e a xs} ->
298297 EffM m t xs (\v => updateResTy v xs prf eff)
299298call e {prf} = callP prf e
300299
301300implicit
302301lift : EffM m t ys ys' ->
303− {default tactics { search 100; }
304− prf : SubList ys xs} ->
302+ {auto prf : SubList ys xs} ->
305303 EffM m t xs (\v => updateWith (ys' v) xs prf)
306304lift e {prf} = liftP prf e
307305
libs/prelude/Language/Reflection.idr+10−8
@@ -215,6 +215,8 @@ data ErrorReportPart =
215215 NamePart TTName |
216216 ||| An Idris term, to be pretty printed
217217 TermPart TT |
218+ ||| A Raw term to be displayed by the compiler
219+ RawPart Raw |
218220 ||| An indented sub-report, to provide more details
219221 SubReport (List ErrorReportPart)
220222%name ErrorReportPart part, p
@@ -576,14 +578,6 @@ mutual
576578 quote (PVar x) = `(PVar {a=TT} ~(assert_total (quote x)))
577579 quote (PVTy x) = `(PVTy {a=TT} ~(assert_total (quote x)))
578580
579−
580−instance Quotable ErrorReportPart TT where
581− quotedTy = `(ErrorReportPart)
582− quote (TextPart x) = `(TextPart ~(quote x))
583− quote (NamePart n) = `(NamePart ~(quote n))
584− quote (TermPart tm) = `(TermPart ~(quote tm))
585− quote (SubReport xs) = `(SubReport ~(assert_total $ quote xs))
586−
587581mutual
588582 quoteRaw : Raw -> TT
589583 quoteRaw (Var n) = `(Var ~(quote n))
@@ -613,6 +607,14 @@ instance Quotable (Binder Raw) TT where
613607 quotedTy = `(Binder Raw)
614608 quote = quoteRawBinder
615609
610+instance Quotable ErrorReportPart TT where
611+ quotedTy = `(ErrorReportPart)
612+ quote (TextPart x) = `(TextPart ~(quote x))
613+ quote (NamePart n) = `(NamePart ~(quote n))
614+ quote (TermPart tm) = `(TermPart ~(quote tm))
615+ quote (RawPart tm) = `(RawPart ~(quote tm))
616+ quote (SubReport xs) = `(SubReport ~(assert_total $ quote xs))
617+
616618instance Quotable Tactic TT where
617619 quotedTy = `(Tactic)
618620 quote (Try tac tac') = `(Try ~(quote tac) ~(quote tac'))
libs/prelude/Language/Reflection/Elab.idr+22−4
@@ -85,6 +85,8 @@ data Elab : Type -> Type where
8585 prim__LookupTy : TTName -> Elab (List (TTName, NameType, TT))
8686 prim__LookupDatatype : TTName -> Elab (List Datatype)
8787
88+ prim__Check : Raw -> Elab (TT, TT)
89+
8890 prim__SourceLocation : Elab SourceLocation
8991
9092 prim__Forget : TT -> Elab Raw
@@ -113,9 +115,10 @@ data Elab : Type -> Type where
113115 prim__AddInstance : TTName -> TTName -> Elab ()
114116
115117 prim__ResolveTC : TTName -> Elab ()
118+ prim__Search : Int -> List TTName -> Elab ()
116119 prim__RecursiveElab : Raw -> Elab () -> Elab (TT, TT)
117120
118− prim__Debug : {a : Type} -> Maybe String -> Elab a
121+ prim__Debug : {a : Type} -> List ErrorReportPart -> Elab a
119122
120123
121124-------------
@@ -186,6 +189,10 @@ namespace Tactics
186189 [] => fail [TextPart "No datatype named", NamePart n]
187190 xs => fail [TextPart "More than one datatype named", NamePart n]
188191
192+ ||| Attempt to type-check a term, getting back itself and its type
193+ check : (tm : Raw) -> Elab (TT, TT)
194+ check tm = prim__Check tm
195+
189196 ||| Convert a type-annotated reflected term to its untyped
190197 ||| equivalent
191198 forgetTypes : TT -> Elab Raw
@@ -306,12 +313,23 @@ namespace Tactics
306313 resolveTC : (fn : TTName) -> Elab ()
307314 resolveTC fn = prim__ResolveTC fn
308315
316+ ||| Use Idris's internal proof search.
317+ search : Elab ()
318+ search = prim__Search 100 []
319+
320+ ||| Use Idris's internal proof search, with more control.
321+ |||
322+ ||| @ depth the search depth
323+ ||| @ hints additional names to try
324+ search' : (depth : Int) -> (hints : List TTName) -> Elab ()
325+ search' depth hints = prim__Search depth hints
326+
309327 ||| Halt elaboration, dumping the internal state for inspection.
310328 |||
311329 ||| This is intended for elaboration script developers, not for
312330 ||| end-users. Use `fail` for final scripts.
313331 debug : Elab a
314− debug = prim__Debug Nothing
332+ debug = prim__Debug []
315333
316334 ||| Halt elaboration, dumping the internal state and displaying a
317335 ||| message.
@@ -320,8 +338,8 @@ namespace Tactics
320338 ||| end-users. Use `fail` for final scripts.
321339 |||
322340 ||| @ msg the message to display
323− debugMessage : (msg : String) -> Elab a
324− debugMessage msg = prim__Debug (Just msg)
341+ debugMessage : (msg : List ErrorReportPart) -> Elab a
342+ debugMessage msg = prim__Debug msg
325343
326344 ||| Recursively invoke the reflected elaborator with some goal.
327345 |||
libs/prelude/Prelude/Basics.idr+2−2
@@ -11,8 +11,8 @@ id x = x
1111
1212||| Manually assign a type to an expression.
1313||| @ a the type to assign
14−||| @ x the element to get the type
15−the : (a : Type) -> (x : a) -> a
14+||| @ value the element to get the type
15+the : (a : Type) -> (value : a) -> a
1616the _ = id
1717
1818||| Constant function. Ignores its second argument.
src/Idris/Core/Binary.hs+2
@@ -18,6 +18,7 @@ instance Binary ErrorReportPart where
1818 put (NamePart n) = do putWord8 1 ; put n
1919 put (TermPart t) = do putWord8 2 ; put t
2020 put (SubReport ps) = do putWord8 3 ; put ps
21+ put (RawPart r) = do putWord8 4 ; put r
2122
2223 get = do i <- getWord8
2324 case i of
@@ -25,6 +26,7 @@ instance Binary ErrorReportPart where
2526 1 -> fmap NamePart get
2627 2 -> fmap TermPart get
2728 3 -> fmap SubReport get
29+ 4 -> fmap RawPart get
2830 _ -> error "Corrupted binary data for ErrorReportPart"
2931
3032instance Binary Provenance where
src/Idris/Core/CaseTree.hs+2
@@ -269,6 +269,8 @@ simpleCase tc defcase reflect phase fc inacc argtys cs erInfo
269269 fstT (x, _, _) = x
270270 lstT (_, _, x) = x
271271
272+ -- Check that all pattern variables are reachable by a case split
273+ -- Otherwise, they won't make sense on the RHS.
272274 chkAccessible (avs, l, c)
273275 | phase == RunTime || reflect = return (l, c)
274276 | otherwise = do mapM_ (acc l) avs
src/Idris/Core/DeepSeq.hs+8−1
@@ -76,7 +76,7 @@ instance NFData Err where
7676 = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` ()
7777 rnf (CantInferType x1) = rnf x1 `seq` ()
7878 rnf (CantMatch x1) = rnf x1 `seq` ()
79− rnf (ReflectionError x1 x2) = x1 `seq` rnf x2 `seq` ()
79+ rnf (ReflectionError x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
8080 rnf (ReflectionFailed x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
8181 rnf (CantSolveGoal x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
8282 rnf (UniqueError x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
@@ -111,6 +111,13 @@ instance NFData Err where
111111 rnf (ElabScriptDebug x1 x2 x3) = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` ()
112112 rnf (ElabScriptStuck x1) = rnf x1 `seq` ()
113113
114+instance NFData ErrorReportPart where
115+ rnf (TextPart x1) = rnf x1 `seq` ()
116+ rnf (TermPart x1) = rnf x1 `seq` ()
117+ rnf (RawPart x1) = rnf x1 `seq` ()
118+ rnf (NamePart x1) = rnf x1 `seq` ()
119+ rnf (SubReport x1) = rnf x1 `seq` ()
120+
114121instance NFData ImplicitInfo where
115122 rnf (Impl x1) = rnf x1 `seq` ()
116123
src/Idris/Core/Elaborate.hs+13−3
@@ -398,9 +398,10 @@ casetac tm = processTactic' (CaseTac tm)
398398equiv :: Raw -> Elab' aux ()
399399equiv tm = processTactic' (Equiv tm)
400400
401−-- | Turn the current hole into a pattern variable with the provided name, made unique if MN
401+-- | Turn the current hole into a pattern variable with the provided
402+-- name, made unique if MN
402403patvar :: Name -> Elab' aux ()
403−patvar n@(SN _) = do apply (Var n) []; solve
404+patvar n@(SN _) = do apply (Var n) []; solve
404405patvar n = do env <- get_env
405406 hs <- get_holes
406407 if (n `elem` map fst env) then do apply (Var n) []; solve
@@ -411,6 +412,15 @@ patvar n = do env <- get_env
411412 x -> return $! n
412413 processTactic' (PatVar n')
413414
415+-- | Turn the current hole into a pattern variable with the provided
416+-- name, but don't make MNs unique.
417+patvar' :: Name -> Elab' aux ()
418+patvar' n@(SN _) = do apply (Var n) [] ; solve
419+patvar' n = do env <- get_env
420+ hs <- get_holes
421+ if (n `elem` map fst env) then do apply (Var n) [] ; solve
422+ else processTactic' (PatVar n)
423+
414424patbind :: Name -> Elab' aux ()
415425patbind n = processTactic' (PatBind n)
416426
@@ -867,7 +877,7 @@ prunStateT pmax zok ps x s
867877 else OK ((v, newpmax, problems p), s')
868878 Error e -> Error e
869879
870−debugElaborator :: Maybe String -> Elab' aux a
880+debugElaborator :: [ErrorReportPart] -> Elab' aux a
871881debugElaborator msg = do ps <- fmap proof get
872882 saveState -- so we don't need to remember the hole order
873883 hs <- get_holes
src/Idris/Core/Evaluate.hs+36−32
@@ -1,5 +1,6 @@
11{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances,
22 PatternGuards #-}
3+{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
34
45module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC, normaliseAll,
56 rt_simplify, simplify, specialise, hnf, convEq, convEq',
@@ -157,6 +158,7 @@ bindEnv ((n, b):bs) tm = Bind n b (bindEnv bs tm)
157158unbindEnv :: EnvTT n -> TT n -> TT n
158159unbindEnv [] tm = tm
159160unbindEnv (_:bs) (Bind n b sc) = unbindEnv bs sc
161+unbindEnv env tm = error $ "Impossible case occurred: couldn't unbind env."
160162
161163usable :: Bool -- specialising
162164 -> Name -> [(Name, Int)] -> Eval (Bool, [(Name, Int)])
@@ -764,6 +766,7 @@ instance Show Totality where
764766 show (Partial (Other ns)) = "possibly not total due to: " ++ showSep ", " (map show ns)
765767 show (Partial (Mutual ns)) = "possibly not total due to recursive path " ++
766768 showSep " --> " (map show ns)
769+ show (Partial (UseUndef n)) = "possibly not total because it uses the undefined name " ++ show n
767770
768771{-!
769772deriving instance Binary Accessibility
@@ -866,22 +869,23 @@ addCasedef :: Name -> ErasureInfo -> CaseInfo ->
866869 [([Name], Term, Term)] -> -- compile time
867870 [([Name], Term, Term)] -> -- inlined
868871 [([Name], Term, Term)] -> -- run time
869− Type -> Context -> Context
872+ Type -> Context -> TC Context
870873addCasedef n ei ci@(CaseInfo inline alwaysInline tcdict)
871874 tcase covering reflect asserted argtys inacc
872875 ps_in ps_tot ps_inl ps_ct ps_rt ty uctxt
873− = let ctxt = definitions uctxt
874− access = case lookupDefAcc n False uctxt of
875− [(_, acc)] -> acc
876− _ -> Public
877− ctxt' = case (simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_tot ei,
878− simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_ct ei,
879− simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_inl ei,
880− simpleCase tcase covering reflect RunTime emptyFC inacc argtys ps_rt ei) of
881− (OK (CaseDef args_tot sc_tot _),
882− OK (CaseDef args_ct sc_ct _),
883− OK (CaseDef args_inl sc_inl _),
884− OK (CaseDef args_rt sc_rt _)) ->
876+ = do let ctxt = definitions uctxt
877+ access = case lookupDefAcc n False uctxt of
878+ [(_, acc)] -> acc
879+ _ -> Public
880+ totalityTime <- simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_tot ei
881+ compileTime <- simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_ct ei
882+ inlined <- simpleCase tcase covering reflect CompileTime emptyFC inacc argtys ps_inl ei
883+ runtime <- simpleCase tcase covering reflect RunTime emptyFC inacc argtys ps_rt ei
884+ ctxt' <- case (totalityTime, compileTime, inlined, runtime) of
885+ (CaseDef args_tot sc_tot _,
886+ CaseDef args_ct sc_ct _,
887+ CaseDef args_inl sc_inl _,
888+ CaseDef args_rt sc_rt _) ->
885889 let inl = alwaysInline -- tcdict
886890 inlc = (inl || small n args_ct sc_ct) && (not asserted)
887891 inlr = inl || small n args_rt sc_rt
@@ -892,28 +896,27 @@ addCasedef n ei ci@(CaseInfo inline alwaysInline tcdict)
892896 op = (CaseOp (ci { case_inlinable = inlc })
893897 ty argtys ps_in ps_tot cdef,
894898 access, Unchecked, EmptyMI)
895− in addDef n op ctxt
896− other -> error ("Error adding case def: " ++ show other)
897− in uctxt { definitions = ctxt' }
899+ in return $ addDef n op ctxt
900+-- other -> tfail (Msg $ "Error adding case def: " ++ show other)
901+ return uctxt { definitions = ctxt' }
898902
899903-- simplify a definition for totality checking
900−simplifyCasedef :: Name -> ErasureInfo -> Context -> Context
904+simplifyCasedef :: Name -> ErasureInfo -> Context -> TC Context
901905simplifyCasedef n ei uctxt
902− = let ctxt = definitions uctxt
903− ctxt' = case lookupCtxt n ctxt of
904− [(CaseOp ci ty atys [] ps _, acc, tot, metainf)] ->
905− ctxt -- nothing to simplify (or already done...)
906− [(CaseOp ci ty atys ps_in ps cd, acc, tot, metainf)] ->
907− let ps_in' = map simpl ps_in
908− pdef = map debind ps_in' in
909− case simpleCase False (STerm Erased) False CompileTime emptyFC [] atys pdef ei of
910− OK (CaseDef args sc _) ->
911− addDef n (CaseOp ci
912− ty atys ps_in' ps (cd { cases_totcheck = (args, sc) }),
913− acc, tot, metainf) ctxt
914− Error err -> error (show err)
915− _ -> ctxt in
916− uctxt { definitions = ctxt' }
906+ = do let ctxt = definitions uctxt
907+ ctxt' <- case lookupCtxt n ctxt of
908+ [(CaseOp ci ty atys [] ps _, acc, tot, metainf)] ->
909+ return ctxt -- nothing to simplify (or already done...)
910+ [(CaseOp ci ty atys ps_in ps cd, acc, tot, metainf)] ->
911+ do let ps_in' = map simpl ps_in
912+ pdef = map debind ps_in'
913+ CaseDef args sc _ <- simpleCase False (STerm Erased) False CompileTime emptyFC [] atys pdef ei
914+ return $ addDef n (CaseOp ci
915+ ty atys ps_in' ps (cd { cases_totcheck = (args, sc) }),
916+ acc, tot, metainf) ctxt
917+
918+ _ -> return ctxt
919+ return uctxt { definitions = ctxt' }
917920 where
918921 depat acc (Bind n (PVar t) sc)
919922 = depat (n : acc) (instantiate (P Bound n t) sc)
@@ -1068,6 +1071,7 @@ lookupVal n ctxt
10681071 case tfst def of
10691072 (Function _ htm) -> return (veval ctxt [] htm)
10701073 (TyDecl nt ty) -> return (VP nt n (veval ctxt [] ty))
1074+ _ -> []
10711075
10721076lookupTyEnv :: Name -> Env -> Maybe (Int, Type)
10731077lookupTyEnv n env = li n 0 env where
src/Idris/Core/TT.hs+50−1
@@ -176,6 +176,7 @@ data OutputAnnotation = AnnName Name (Maybe NameOutput) (Maybe String) (Maybe St
176176data ErrorReportPart = TextPart String
177177 | NamePart Name
178178 | TermPart Term
179+ | RawPart Raw
179180 | SubReport [ErrorReportPart]
180181 deriving (Show, Eq, Data, Typeable)
181182
@@ -244,7 +245,7 @@ data Err' t
244245 | LoadingFailed String (Err' t)
245246 | ReflectionError [[ErrorReportPart]] (Err' t)
246247 | ReflectionFailed String (Err' t)
247− | ElabScriptDebug (Maybe String) t [(Name, t, [(Name, Binder t)])]
248+ | ElabScriptDebug [ErrorReportPart] t [(Name, t, [(Name, Binder t)])]
248249 -- ^ User-specified message, proof term, goals with context (first goal is focused)
249250 | ElabScriptStuck t
250251 deriving (Eq, Functor, Data, Typeable)
@@ -288,6 +289,7 @@ deriving instance NFData Err
288289instance Sized ErrorReportPart where
289290 size (TextPart msg) = 1 + length msg
290291 size (TermPart t) = 1 + size t
292+ size (RawPart r) = 1 + size r
291293 size (NamePart n) = 1 + size n
292294 size (SubReport rs) = 1 + size rs
293295
@@ -1715,6 +1717,53 @@ pprintTT bound tm = pp startPrec bound tm
17151717 | outer > inner = lparen <> doc <> rparen
17161718 | otherwise = doc
17171719
1720+-- | Pretty-print a raw term.
1721+pprintRaw :: [Name] -- ^ Bound names, for highlighting
1722+ -> Raw -- ^ The term to pretty-print
1723+ -> Doc OutputAnnotation
1724+pprintRaw bound (Var n) =
1725+ enclose lparen rparen . group . align . hang 2 $
1726+ (text "Var") <$> annotate (if n `elem` bound
1727+ then AnnBoundName n False
1728+ else AnnName n Nothing Nothing Nothing)
1729+ (text $ show n)
1730+pprintRaw bound (RBind n b body) =
1731+ enclose lparen rparen . group . align . hang 2 $
1732+ vsep [ text "RBind"
1733+ , annotate (AnnBoundName n False) (text $ show n)
1734+ , ppb b
1735+ , pprintRaw (n:bound) body]
1736+ where
1737+ ppb (Lam ty) = enclose lparen rparen . group . align . hang 2 $
1738+ text "Lam" <$> pprintRaw bound ty
1739+ ppb (Pi _ ty k) = enclose lparen rparen . group . align . hang 2 $
1740+ vsep [text "Pi", pprintRaw bound ty, pprintRaw bound k]
1741+ ppb (Let ty v) = enclose lparen rparen . group . align . hang 2 $
1742+ vsep [text "Let", pprintRaw bound ty, pprintRaw bound v]
1743+ ppb (NLet ty v) = enclose lparen rparen . group . align . hang 2 $
1744+ vsep [text "NLet", pprintRaw bound ty, pprintRaw bound v]
1745+ ppb (Hole ty) = enclose lparen rparen . group . align . hang 2 $
1746+ text "Hole" <$> pprintRaw bound ty
1747+ ppb (GHole _ ty) = enclose lparen rparen . group . align . hang 2 $
1748+ text "GHole" <$> pprintRaw bound ty
1749+ ppb (Guess ty v) = enclose lparen rparen . group . align . hang 2 $
1750+ vsep [text "Guess", pprintRaw bound ty, pprintRaw bound v]
1751+ ppb (PVar ty) = enclose lparen rparen . group . align . hang 2 $
1752+ text "PVar" <$> pprintRaw bound ty
1753+ ppb (PVTy ty) = enclose lparen rparen . group . align . hang 2 $
1754+ text "PVTy" <$> pprintRaw bound ty
1755+pprintRaw bound (RApp f x) =
1756+ enclose lparen rparen . group . align . hang 2 . vsep $
1757+ [text "RApp", pprintRaw bound f, pprintRaw bound x]
1758+pprintRaw bound RType = text "RType"
1759+pprintRaw bound (RUType u) = enclose lparen rparen . group . align . hang 2 $
1760+ text "RUType" <$> text (show u)
1761+pprintRaw bound (RForce r) =
1762+ enclose lparen rparen . group . align . hang 2 $
1763+ vsep [text "RForce", pprintRaw bound r]
1764+pprintRaw bound (RConstant c) =
1765+ enclose lparen rparen . group . align . hang 2 $
1766+ vsep [text "RConstant", annotate (AnnConst c) (text (show c))]
17181767
17191768-- | Pretty-printer helper for the binding site of a name
17201769bindingOf :: Name -- ^^ the bound name
src/Idris/Coverage.hs+3−1
@@ -423,7 +423,9 @@ checkTotality path fc n
423423 | otherwise = do
424424 t <- getTotality n
425425 i <- getIState
426− updateContext (simplifyCasedef n $ getErasureInfo i)
426+ ctxt' <- do ctxt <- getContext
427+ tclift $ simplifyCasedef n (getErasureInfo i) ctxt
428+ setContext ctxt'
427429 ctxt <- getContext
428430 i <- getIState
429431 let opts = case lookupCtxt n (idris_flags i) of
src/Idris/DeepSeq.hs−6
@@ -310,12 +310,6 @@ instance (NFData t) => NFData (PTactic' t) where
310310 rnf SourceFC = ()
311311 rnf Unfocus = ()
312312
313−instance NFData ErrorReportPart where
314− rnf (TermPart x1) = rnf x1 `seq` ()
315− rnf (TextPart x1) = rnf x1 `seq` ()
316− rnf (NamePart x1) = rnf x1 `seq` ()
317− rnf (SubReport x1) = rnf x1 `seq` ()
318−
319313instance (NFData t) => NFData (PDo' t) where
320314 rnf (DoExp x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
321315 rnf (DoBind x1 x2 x3 x4) = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` ()
src/Idris/Delaborate.hs+12−10
@@ -382,19 +382,19 @@ pprintErr' i (AlreadyDefined n) = annName n<+>
382382pprintErr' i (ProofSearchFail e) = pprintErr' i e
383383pprintErr' i (NoRewriting tm) = text "rewrite did not change type" <+> annTm tm (pprintTerm i (delabSugared i tm))
384384pprintErr' i (At f e) = annotate (AnnFC f) (text (show f)) <> colon <> pprintErr' i e
385−pprintErr' i (Elaborating s n e) = text "When elaborating" <+> text s <>
385+pprintErr' i (Elaborating s n e) = text "When checking" <+> text s <>
386386 annName' n (showqual i n) <> colon <$>
387387 pprintErr' i e
388388pprintErr' i (ElaboratingArg f x _ e)
389389 | isInternal f = pprintErr' i e
390390 | isUN x =
391− text "When elaborating argument" <+>
391+ text "When checking argument" <+>
392392 annotate (AnnBoundName x False) (text (showbasic x)) <+> -- TODO check plicity
393393 -- Issue #1591 on the issue tracker: https://github.com/idris-lang/Idris-dev/issues/1591
394394 text "to" <+> whatIsName <> annName f <> colon <>
395395 indented (pprintErr' i e)
396396 | otherwise =
397− text "When elaborating an application of" <+> whatIsName <>
397+ text "When checking an application of" <+> whatIsName <>
398398 annName f <> colon <> indented (pprintErr' i e)
399399 where whatIsName = let ctxt = tt_ctxt i
400400 in if isTConName f ctxt
@@ -412,23 +412,18 @@ pprintErr' i (ElaboratingArg f x _ e)
412412pprintErr' i (ProviderError msg) = text ("Type provider error: " ++ msg)
413413pprintErr' i (LoadingFailed fn e) = text "Loading" <+> text fn <+> text "failed:" <+> pprintErr' i e
414414pprintErr' i (ReflectionError parts orig) =
415− let parts' = map (fillSep . map showPart) parts in
415+ let parts' = map (fillSep . map (showPart i)) parts in
416416 align (fillSep parts') <>
417417 if (opt_origerr (idris_options i))
418418 then line <> line <> text "Original error:" <$> indented (pprintErr' i orig)
419419 else empty
420− where showPart :: ErrorReportPart -> Doc OutputAnnotation
421− showPart (TextPart str) = fillSep . map text . words $ str
422− showPart (NamePart n) = annName n
423− showPart (TermPart tm) = pprintTerm i (delabSugared i tm)
424− showPart (SubReport rs) = indented . hsep . map showPart $ rs
425420pprintErr' i (ReflectionFailed msg err) =
426421 text "When attempting to perform error reflection, the following internal error occurred:" <>
427422 indented (pprintErr' i err) <>
428423 text ("This is probably a bug. Please consider reporting it at " ++ bugaddr)
429424pprintErr' i (ElabScriptDebug msg tm holes) =
430425 text "Elaboration halted." <>
431− maybe empty (indented . text) msg <>
426+ indented (align . hsep $ map (showPart i) msg) <>
432427 line <> line <>
433428 text "Holes:" <>
434429 indented (vsep (map ppHole holes)) <> line <> line <>
@@ -452,6 +447,13 @@ pprintErr' i (ElabScriptStuck tm) =
452447 text "Can't run" <+> pprintTT [] tm <+> text "as an elaborator script." <$>
453448 text "Is it a stuck term?"
454449
450+showPart :: IState -> ErrorReportPart -> Doc OutputAnnotation
451+showPart ist (TextPart str) = fillSep . map text . words $ str
452+showPart ist (NamePart n) = annName n
453+showPart ist (TermPart tm) = pprintTerm ist (delabSugared ist tm)
454+showPart ist (RawPart tm) = pprintRaw [] tm
455+showPart ist (SubReport rs) = indented . hsep . map (showPart ist) $ rs
456+
455457-- | Make sure the machine invented names are shown helpfully to the user, so
456458-- that any names which differ internally also differ visibly
457459renameMNs :: Term -> Term -> (Term, Term, [Name])
src/Idris/Elab/Clause.hs+8−4
@@ -224,17 +224,21 @@ elabClauses info' fc opts n_in cs =
224224 (idris_patdefs ist) })
225225 let caseInfo = CaseInfo (inlinable opts) (inlinable opts) (dictionary opts)
226226 case lookupTy n ctxt of
227− [ty] -> do updateContext (addCasedef n erInfo caseInfo
227+ [ty] -> do ctxt' <- do ctxt <- getContext
228+ tclift $
229+ addCasedef n erInfo caseInfo
228230 tcase defaultcase
229231 reflect
230232 (AssertTotal `elem` opts)
231233 atys
232234 inacc
233235 pats_pe
234− pdef
235− pdef -- compile time
236+ pdef
237+ pdef -- compile time
236238 pdef_inl -- inlined
237− pdef' ty)
239+ pdef' ty
240+ ctxt
241+ setContext ctxt'
238242 addIBC (IBCDef n)
239243 setTotality n tot
240244 when (not reflect) $ do totcheck (fc, n)
src/Idris/Elab/Term.hs+52−27
@@ -1730,21 +1730,27 @@ runTactical ist fc env tm = do tm' <- eval tm
17301730 Left lhs -> let (ns, lhs') = patvars [] lhs'
17311731 in (ns, lhs', Impossible))
17321732 clauses'
1733− set_context $
1734− addCasedef n (const [])
1735− info False (STerm Erased)
1736− True False -- TODO what are these?
1737− (map snd $ getArgTys ty) [] -- TODO inaccessible types
1738− clauses'
1739− clauses''
1740− clauses''
1741− clauses''
1742− clauses''
1743− ty
1744− ctxt
1733+ ctxt'<- lift $
1734+ addCasedef n (const [])
1735+ info False (STerm Erased)
1736+ True False -- TODO what are these?
1737+ (map snd $ getArgTys ty) [] -- TODO inaccessible types
1738+ clauses'
1739+ clauses''
1740+ clauses''
1741+ clauses''
1742+ clauses''
1743+ ty
1744+ ctxt
1745+ set_context ctxt'
17451746 updateAux $ \e -> e { new_tyDecls = RClausesInstrs n clauses'' : new_tyDecls e}
17461747 return ()
17471748
1749+ checkClosed :: Raw -> Elab' aux (Term, Type)
1750+ checkClosed tm = do ctxt <- get_context
1751+ (val, ty) <- lift $ check ctxt [] tm
1752+ return $! (finalise val, finalise ty)
1753+
17481754 -- | Do a step in the reflected elaborator monad. The input is the
17491755 -- step, the output is the (reflected) term returned.
17501756 runTacTm :: Term -> ElabD Term
@@ -1755,12 +1761,12 @@ runTactical ist fc env tm = do tm' <- eval tm
17551761 | n == tacN "prim__Goal", [] <- args
17561762 = do (h:_) <- get_holes
17571763 t <- goal
1758− fmap fst . get_type_val $
1764+ fmap fst . checkClosed $
17591765 rawPair (Var (reflm "TTName"), Var (reflm "TT"))
17601766 (reflectName h, reflect t)
17611767 | n == tacN "prim__Holes", [] <- args
17621768 = do hs <- get_holes
1763− fmap fst . get_type_val $
1769+ fmap fst . checkClosed $
17641770 mkList (Var $ reflm "TTName") (map reflectName hs)
17651771 | n == tacN "prim__Guess", [] <- args
17661772 = do ok <- is_guess
@@ -1770,7 +1776,7 @@ runTactical ist fc env tm = do tm' <- eval tm
17701776 RApp (RApp (Var (sNS (sUN "Just") ["Maybe", "Prelude"]))
17711777 (Var (reflm "TT")))
17721778 guess
1773− else fmap fst . get_type_val $
1779+ else fmap fst . checkClosed $
17741780 RApp (Var (sNS (sUN "Nothing") ["Maybe", "Prelude"]))
17751781 (Var (reflm "TT"))
17761782 | n == tacN "prim__LookupTy", [n] <- args
@@ -1790,7 +1796,7 @@ runTactical ist fc env tm = do tm' <- eval tm
17901796 let defs = [ reflectTriple (reflectName n, reflectNameType nt, reflect ty)
17911797 | (n, def) <- lookupNameDef n' ctxt
17921798 , let (nt, ty) = getNameTypeAndType def ]
1793− fmap fst . get_type_val $
1799+ fmap fst . checkClosed $
17941800 rawList (raw_apply (Var pairTy) [ Var (reflm "TTName")
17951801 , raw_apply (Var pairTy) [ Var (reflm "NameType")
17961802 , Var (reflm "TT")]])
@@ -1799,15 +1805,15 @@ runTactical ist fc env tm = do tm' <- eval tm
17991805 = do n' <- reifyTTName name
18001806 datatypes <- get_datatypes
18011807 ctxt <- get_context
1802− fmap fst . get_type_val $
1808+ fmap fst . checkClosed $
18031809 rawList (Var (tacN "Datatype"))
18041810 (map reflectDatatype (buildDatatypes ctxt datatypes n'))
18051811 | n == tacN "prim__SourceLocation", [] <- args
1806− = fmap fst . get_type_val $
1812+ = fmap fst . checkClosed $
18071813 reflectFC fc
18081814 | n == tacN "prim__Env", [] <- args
18091815 = do env <- get_env
1810− fmap fst . get_type_val $ reflectEnv env
1816+ fmap fst . checkClosed $ reflectEnv env
18111817 | n == tacN "prim__Fail", [_a, errs] <- args
18121818 = do errs' <- eval errs
18131819 parts <- reifyReportParts errs'
@@ -1843,9 +1849,17 @@ runTactical ist fc env tm = do tm' <- eval tm
18431849 ty' <- reifyRaw ty
18441850 claim n' ty'
18451851 returnUnit
1852+ | n == tacN "prim__Check", [raw] <- args
1853+ = do raw' <- reifyRaw =<< eval raw
1854+ ctxt <- get_context
1855+ env <- get_env
1856+ (tm, ty) <- lift $ check ctxt env raw'
1857+ fmap fst . checkClosed $
1858+ rawPair (Var (reflm "TT"), Var (reflm "TT"))
1859+ (reflect tm, reflect ty)
18461860 | n == tacN "prim__Forget", [tt] <- args
18471861 = do tt' <- reifyTT tt
1848− fmap fst . get_type_val . reflectRaw $ forget tt'
1862+ fmap fst . checkClosed . reflectRaw $ forget tt'
18491863 | n == tacN "prim__Attack", [] <- args
18501864 = do attack
18511865 returnUnit
@@ -1874,7 +1888,7 @@ runTactical ist fc env tm = do tm' <- eval tm
18741888 returnUnit
18751889 | n == tacN "prim__PatVar", [n] <- args
18761890 = do n' <- reifyTTName n
1877− patvar n'
1891+ patvar' n'
18781892 returnUnit
18791893 | n == tacN "prim__PatBind", [n] <- args
18801894 = do n' <- reifyTTName n
@@ -1921,6 +1935,19 @@ runTactical ist fc env tm = do tm' <- eval tm
19211935 fn <- reifyTTName fn
19221936 resolveTC False True 100 g fn ist
19231937 returnUnit
1938+ | n == tacN "prim__Search", [depth, hints] <- args
1939+ = do d <- eval depth
1940+ hints' <- eval hints
1941+ case (d, unList hints') of
1942+ (Constant (I i), Just hs) ->
1943+ do actualHints <- mapM reifyTTName hs
1944+ unifyProblems
1945+ let psElab = elab ist toplevel ERHS [] (sMN 0 "tac")
1946+ proofSearch True True False False i psElab Nothing (sMN 0 "search ") actualHints ist
1947+ returnUnit
1948+ (Constant (I _), Nothing ) ->
1949+ lift . tfail . InternalMsg $ "Not a list: " ++ show hints'
1950+ (_, _) -> lift . tfail . InternalMsg $ "Can't reify int " ++ show d
19241951 | n == tacN "prim__RecursiveElab", [goal, script] <- args
19251952 = do goal' <- reifyRaw goal
19261953 ctxt <- get_context
@@ -1939,15 +1966,13 @@ runTactical ist fc env tm = do tm' <- eval tm
19391966 env' <- get_env
19401967 (tm, ty, _) <- lift $ recheck ctxt env (forget tm_out) tm_out
19411968 let (tm', ty') = (reflect tm, reflect ty)
1942− fmap fst . get_type_val $
1969+ fmap fst . checkClosed $
19431970 rawPair (Var $ reflm "TT", Var $ reflm "TT")
19441971 (tm', ty')
19451972 | n == tacN "prim__Debug", [ty, msg] <- args
1946− = do let msg' = fromTTMaybe msg
1947− case msg' of
1948− Nothing -> debugElaborator Nothing
1949− Just (Constant (Str m)) -> debugElaborator (Just m)
1950− Just x -> lift . tfail . InternalMsg $ "Can't reify message for debugging: " ++ show x
1973+ = do msg' <- eval msg
1974+ parts <- reifyReportParts msg
1975+ debugElaborator parts
19511976 runTacTm x = lift . tfail $ ElabScriptStuck x
19521977
19531978-- Running tactics directly
src/Idris/ElabDecls.hs+3−1
@@ -195,7 +195,9 @@ elabDecl' what info (PMutual f ps)
195195 -- Do totality checking after entire mutual block
196196 i <- get
197197 mapM_ (\n -> do logLvl 5 $ "Simplifying " ++ show n
198− updateContext (simplifyCasedef n $ getErasureInfo i))
198+ ctxt' <- do ctxt <- getContext
199+ tclift $ simplifyCasedef n (getErasureInfo i) ctxt
200+ setContext ctxt')
199201 (map snd (idris_totcheck i))
200202 mapM_ buildSCG (idris_totcheck i)
201203 mapM_ checkDeclTotality (idris_totcheck i)
src/Idris/IBC.hs+1−1
@@ -41,7 +41,7 @@ import Codec.Archive.Zip
4141import Util.Zlib (decompressEither)
4242
4343ibcVersion :: Word16
44−ibcVersion = 110
44+ibcVersion = 111
4545
4646data IBCFile = IBCFile { ver :: Word16,
4747 sourcefile :: FilePath,
src/Idris/Interactive.hs+1−1
@@ -162,7 +162,7 @@ makeWith fn updatefile l n
162162doProofSearch :: FilePath -> Bool -> Bool ->
163163 Int -> Name -> [Name] -> Maybe Int -> Idris ()
164164doProofSearch fn updatefile rec l n hints Nothing
165− = doProofSearch fn updatefile rec l n hints (Just 10)
165+ = doProofSearch fn updatefile rec l n hints (Just 20)
166166doProofSearch fn updatefile rec l n hints (Just depth)
167167 = do src <- runIO $ readSource fn
168168 let (before, tyline : later) = splitAt (l-1) (lines src)
src/Idris/Parser.hs+16−7
@@ -1271,12 +1271,18 @@ parseImports fname input
12711271
12721272-- | There should be a better way of doing this...
12731273findFC :: Doc -> (FC, String)
1274−findFC x = let s = show (plain x) in
1275− case span (/= ':') s of
1276− (failname, ':':rest) -> case span isDigit rest of
1277− (line, ':':rest') -> case span isDigit rest' of
1278− (col, ':':msg) -> let pos = (read line, read col) in
1279− (FC failname pos pos, msg)
1274+findFC x = let s = show (plain x) in findFC' s
1275+ where findFC' s = case span (/= ':') s of
1276+ -- Horrid kludge to prevent crashes on Windows
1277+ (prefix, ':':'\\':rest) ->
1278+ case findFC' rest of
1279+ (NoFC, msg) -> (NoFC, msg)
1280+ (FileFC f, msg) -> (FileFC (prefix ++ ":\\" ++ f), msg)
1281+ (FC f start end, msg) -> (FC (prefix ++ ":\\" ++ f) start end, msg)
1282+ (failname, ':':rest) -> case span isDigit rest of
1283+ (line, ':':rest') -> case span isDigit rest' of
1284+ (col, ':':msg) -> let pos = (read line, read col) in
1285+ (FC failname pos pos, msg)
12801286
12811287-- | Check if the coloring matches the options and corrects if necessary
12821288fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
@@ -1468,7 +1474,10 @@ loadSource lidr f toline
14681474 -- simplify every definition do give the totality checker
14691475 -- a better chance
14701476 mapM_ (\n -> do logLvl 5 $ "Simplifying " ++ show n
1471− updateContext (simplifyCasedef n $ getErasureInfo i))
1477+ ctxt' <-
1478+ do ctxt <- getContext
1479+ tclift $ simplifyCasedef n (getErasureInfo i) ctxt
1480+ setContext ctxt')
14721481 (map snd (idris_totcheck i))
14731482 -- build size change graph from simplified definitions
14741483 iLOG "Totality checking"
src/Idris/Prover.hs+10−7
@@ -86,13 +86,16 @@ prove opt ctxt lit n ty
8686 Error e -> ierror (CantUnify False (ty, Nothing) (pty, Nothing) e [] 0)
8787 ptm' <- applyOpts ptm
8888 ei <- getErasureInfo `fmap` getIState
89− updateContext (addCasedef n ei (CaseInfo True True False) False (STerm Erased) True False
90− [] [] -- argtys, inaccArgs
91− [Right (P Ref n ty, ptm)]
92− [([], P Ref n ty, ptm)]
93− [([], P Ref n ty, ptm)]
94− [([], P Ref n ty, ptm)]
95− [([], P Ref n ty, ptm')] ty)
89+ ctxt' <- do ctxt <- getContext
90+ tclift $ addCasedef n ei (CaseInfo True True False) False (STerm Erased) True False
91+ [] [] -- argtys, inaccArgs
92+ [Right (P Ref n ty, ptm)]
93+ [([], P Ref n ty, ptm)]
94+ [([], P Ref n ty, ptm)]
95+ [([], P Ref n ty, ptm)]
96+ [([], P Ref n ty, ptm')] ty
97+ ctxt
98+ setContext ctxt'
9699 solveDeferred n
97100 case idris_outputmode i of
98101 IdeMode n h ->
src/Idris/Reflection.hs+8
@@ -913,6 +913,14 @@ reifyReportPart (App _ (P (DCon _ _ _) n _) tm)
913913 show tm ++
914914 " when reflecting an error:" ++ show e
915915 OK (tm', _) -> Right $ TermPart tm'
916+reifyReportPart (App _ (P (DCon _ _ _) n _) tm)
917+ | n == reflm "RawPart" =
918+ case runElab initEState (reifyRaw tm) (initElaborator NErased initContext emptyContext Erased) of
919+ Error e -> Left . InternalMsg $
920+ "could not reify reflected raw term " ++
921+ show tm ++
922+ " when reflecting an error: " ++ show e
923+ OK (tm', _) -> Right $ RawPart tm'
916924reifyReportPart (App _ (P (DCon _ _ _) n _) tm)
917925 | n == reflm "SubReport" =
918926 case unList tm of
test/basic006/expected+2−2
@@ -1,5 +1,5 @@
1−test020a.idr:16:18:When elaborating right hand side of foo:
2−When elaborating an application of function Prelude.List.reverse:
1+test020a.idr:16:18:When checking right hand side of foo:
2+When checking an application of function Prelude.List.reverse:
33 Type mismatch between
44 Vect n a (Type of xs)
55 and
test/basic009/expected+1−1
@@ -1,4 +1,4 @@
11MAIN-PASS
2−Faulty.idr:6:7:When elaborating type of Faulty.fault:
2+Faulty.idr:6:7:When checking type of Faulty.fault:
33Can't disambiguate name: A.num, B.C.num
44Multiple.idr:3:1:import alias not unique: "X"
test/error003/expected+1−2
@@ -1,3 +1,2 @@
1−ErrorReflection.idr:68:5:
2−When elaborating right hand side of bad:
1+ErrorReflection.idr:68:5:When checking right hand side of bad:
32DSL type error: (t(503) => t'(504)) doesn't match ()
test/error004/expected+7−7
@@ -1,8 +1,8 @@
1−FunErrTest.idr:35:10:
2−When elaborating right hand side of badCadr1:
3−When elaborating argument cons1 to function FunErrTest.cadr:
1+FunErrTest.idr:35:10:When checking right hand side of badCadr1:
2+When checking argument cons1 to function FunErrTest.cadr:
43 Could not prove that [] has at least two elements.
5−FunErrTest.idr:38:10:
6−When elaborating right hand side of badCadr2:
7−When elaborating argument cons2 to function FunErrTest.cadr:
8− Could not prove that tail [1] has at least two elements.
4+FunErrTest.idr:38:10:When checking right hand side of badCadr2:
5+When checking argument cons2 to function FunErrTest.cadr:
6+ Could not prove that tail [1] has at least two
7+ elements.
8+
test/error005/expected+10−10
@@ -1,21 +1,21 @@
1−error005.idr:13:1:When elaborating right hand side of two:
2−When elaborating argument prf to function Data.Fin.fromInteger:
1+error005.idr:13:1:When checking right hand side of two:
2+When checking argument prf to function Data.Fin.fromInteger:
33 When using 2 as a literal for a Fin 2
44 2 is not strictly less than 2
5−error005.idr:16:1:When elaborating right hand side of hahaha:
6−When elaborating argument prf to function Data.Fin.fromInteger:
5+error005.idr:16:1:When checking right hand side of hahaha:
6+When checking argument prf to function Data.Fin.fromInteger:
77 When using 0 as a literal for a Fin n
88 0 is not strictly less than n
9−error005.idr:22:1:When elaborating right hand side of notOk:
10−When elaborating argument prf to function Data.Fin.fromInteger:
9+error005.idr:22:1:When checking right hand side of notOk:
10+When checking argument prf to function Data.Fin.fromInteger:
1111 When using 2 as a literal for a Fin (S (S n))
1212 2 is not strictly less than S (S n)
13−error005.idr:23:24:When elaborating right hand side of b0rken:
14−When elaborating argument prf to function Data.Fin.fromInteger:
13+error005.idr:23:24:When checking right hand side of b0rken:
14+When checking argument prf to function Data.Fin.fromInteger:
1515 When using n as a literal for a Fin 3
1616 Could not show that n is less than 3 because n is a bound
1717 variable instead of a constant Integer
18−error005.idr:28:1:When elaborating right hand side of x:
19−When elaborating argument prf to function Data.Fin.fromInteger:
18+error005.idr:28:1:When checking right hand side of x:
19+When checking argument prf to function Data.Fin.fromInteger:
2020 When using 5 as a literal for a Fin 4
2121 5 is not strictly less than 4
test/meta002/expected+1−1
@@ -1,3 +1,3 @@
11Tacs.idr:247:15:
2−When elaborating right hand side of testElab3:
2+When checking right hand side of testElab3:
33Unifying ty and ARR ty t would lead to infinite value
test/proof002/expected+2−2
@@ -1,6 +1,6 @@
11Reflect.idr:208:38:
2−When elaborating right hand side of testReflect1:
3−When elaborating an application of function Reflect.getJust:
2+When checking right hand side of testReflect1:
3+When checking an application of function Reflect.getJust:
44 Type mismatch between
55 IsJust (Just x1) (Type of ItIsJust)
66 and
test/proof007/expected+2−2
@@ -1,4 +1,4 @@
11DefaultArgUnknownName.idr:9:6:
2−When elaborating right hand side of test:
3−When elaborating argument arg to function DefaultArgUnknownName.funWithBadDefArg:
2+When checking right hand side of test:
3+When checking argument arg to function DefaultArgUnknownName.funWithBadDefArg:
44 No such variable sadgjhsag
test/quasiquote003/expected+1−1
@@ -1,2 +1,2 @@
1−NoInfer.idr:11:5:When elaborating right hand side of zzz:
1+NoInfer.idr:11:5:When checking right hand side of zzz:
22No such variable k
test/quasiquote004/expected+1−1
@@ -1,3 +1,3 @@
11Quasiquote004.idr:50:25:
2−When elaborating right hand side of Quasiquote004.getMeNat':
2+When checking right hand side of Quasiquote004.getMeNat':
33Not a Nat goal
test/quasiquote006/expected+3−3
@@ -1,12 +1,12 @@
11quasiquote006.idr:9:3:
2−When elaborating right hand side of b:
2+When checking right hand side of b:
33Can't disambiguate name: ForeignEnv.Nil,
44 Prelude.List.Nil
55quasiquote006.idr:12:3:
6−When elaborating right hand side of c:
6+When checking right hand side of c:
77No such variable alsdkjflkj
88quasiquote006.idr:15:3:
9−When elaborating right hand side of d:
9+When checking right hand side of d:
1010Can't disambiguate name: ForeignEnv.::,
1111 Prelude.List.::,
1212 Prelude.Stream.::
test/reg003/expected+3−3
@@ -1,6 +1,6 @@
1−reg003a.idr:4:11:When elaborating type of Main.ECons:
1+reg003a.idr:4:11:When checking type of Main.ECons:
22No such variable OddList
3−reg003a.idr:7:11:When elaborating type of Main.OCons:
3+reg003a.idr:7:11:When checking type of Main.OCons:
44No such variable EvenList
5−reg003a.idr:9:6:When elaborating type of Main.test:
5+reg003a.idr:9:6:When checking type of Main.test:
66No such variable EvenList
test/reg007/expected+1−1
@@ -1,5 +1,5 @@
11reg007.lidr:8:1:A.n is already defined
2−reg007.lidr:12:11-17:When elaborating right hand side of hurrah:
2+reg007.lidr:12:11-17:When checking right hand side of hurrah:
33Type mismatch between
44 n = lala (Type of isSame)
55and
test/reg010/expected+1−1
@@ -1,3 +1,3 @@
11reg010.idr:5:15:
2−When elaborating left hand side of with block in usubst.unsafeSubst:
2+When checking left hand side of with block in usubst.unsafeSubst:
33Can't match on with block in usubst.unsafeSubst warg a P x x px
test/reg023/expected+1−1
@@ -1,4 +1,4 @@
1−reg023.idr:7:5:When elaborating right hand side of bad:
1+reg023.idr:7:5:When checking right hand side of bad:
22Type mismatch between
33 Nat (Type of 0)
44and
test/reg034/expected+2−2
@@ -1,4 +1,4 @@
1−reg034.idr:6:5:When elaborating left hand side of bar:
1+reg034.idr:6:5:When checking left hand side of bar:
22Can't match on bar xs xs Refl
3−reg034.idr:9:5:When elaborating left hand side of foo:
3+reg034.idr:9:5:When checking left hand side of foo:
44Can't match on foo f x x Refl
test/reg044/expected+1−1
@@ -1,4 +1,4 @@
1−reg044.idr:4:4:When elaborating right hand side of Main.pf:
1+reg044.idr:4:4:When checking right hand side of Main.pf:
22Type mismatch between
33 b = b (Type of Refl)
44and
test/reg049/expected+2−2
@@ -1,4 +1,4 @@
1−reg049.idr:2:9:When elaborating constructor Main.Bogus:
1+reg049.idr:2:9:When checking constructor Main.Bogus:
22Void is not Main.Foo
3−reg049.idr:5:6:When elaborating right hand side of uhOh:
3+reg049.idr:5:6:When checking right hand side of uhOh:
44No such variable Bogus
test/reg054/expected+6−6
@@ -1,11 +1,11 @@
1−reg054.idr:18:5:When elaborating left hand side of inf:
2−When elaborating an application of constructor Main.MkInfer:
1+reg054.idr:18:5:When checking left hand side of inf:
2+When checking an application of constructor Main.MkInfer:
33 Attempting concrete match on polymorphic argument: 0
4−reg054.idr:34:7:When elaborating left hand side of weird:
5−When elaborating argument x to Main.weird:
4+reg054.idr:34:7:When checking left hand side of weird:
5+When checking argument x to Main.weird:
66 No explicit types on left hand side: Char
7−reg054.idr:37:1-8:When elaborating left hand side of tctrick:
8−When elaborating an application of Main.tctrick:
7+reg054.idr:37:1-8:When checking left hand side of tctrick:
8+When checking an application of Main.tctrick:
99 Type mismatch between
1010 Maybe a1 (Type of Just x)
1111 and
test/reg055/expected+5−5
@@ -1,9 +1,9 @@
1−reg055.idr:5:3:When elaborating left hand side of g:
1+reg055.idr:5:3:When checking left hand side of g:
22Can't match on g (f 0)
3−reg055.idr:8:3:When elaborating left hand side of h:
3+reg055.idr:8:3:When checking left hand side of h:
44Can't match on h x x
5−reg055a.idr:8:5:When elaborating left hand side of foo:
6−When elaborating an application of constructor Foo.CAny:
5+reg055a.idr:8:5:When checking left hand side of foo:
6+When checking an application of constructor Foo.CAny:
77 Attempting concrete match on polymorphic argument: Nothing
8−reg055a.idr:13:7:When elaborating left hand side of Foo.apply:
8+reg055a.idr:13:7:When checking left hand side of Foo.apply:
99Can't match on apply (\x => \y => x) a
test/tutorial006/expected+3−4
@@ -1,6 +1,5 @@
1−tutorial006a.idr:5:23-25:
2−When elaborating right hand side of vapp:
3−When elaborating argument xs to constructor Data.VectType.Vect.:::
1+tutorial006a.idr:5:23-25:When checking right hand side of vapp:
2+When checking argument xs to constructor Data.VectType.Vect.:::
43 Type mismatch between
54 Vect (n + n) a (Type of vapp xs xs)
65 and
@@ -12,7 +11,7 @@ When elaborating argument xs to constructor Data.VectType.Vect.:::
1211 and
1312 plus n m
1413tutorial006b.idr:10:10:
15−When elaborating right hand side of with block in Main.parity:
14+When checking right hand side of with block in Main.parity:
1615Type mismatch between
1716 Parity (plus (S j) (S j)) (Type of even)
1817and