Commit Graph

170 Commits

Author SHA1 Message Date
Guillaume Allais
6e2ccb085e [ more ] show the diff in case of mismatch 2020-04-06 11:29:18 +01:00
Guillaume Allais
5ae54488d7 [ new ] interactive test runner 2020-04-06 11:06:19 +01:00
Guillaume Allais
4cbb02b6b3 [ fix ] properly nesting multiline comments
We should be able to comment out any part of a program that parses
and still get a program that parses. This means we need to properly
ignore `{-` and `-}` when hidden behind a `--` comment or inside of
a string literal.
2020-04-01 12:52:01 +01:00
Marc Petit-Huguenin
7ea39af60e
Literate programming
- Add support for .lidr files.
- Add new Parse Error for Literate fails.
- Add support for Case Split.
- Add support for Add Clause.
- Add support for Add Lemma.
- Add tests.
2020-03-29 11:58:00 -07:00
Edwin Brady
bce7a5e747
Merge pull request #205 from abailly/syntax-highlight
first stab at syntax highlighting in Emacs
2020-03-27 00:22:19 +00:00
Edwin Brady
cbf8785d32 Take account of env in record elaboration
Also need to make sure that the constructor and fields are included in
the nested names so that the parameters get expanded properly.
Fixes #138
2020-03-19 12:12:25 +00:00
Edwin Brady
3cf223b835 Elaborate record bodies on second mutual pass
This is the same behaviour as Idris 1. Fixes #217
2020-03-18 23:09:17 +00:00
Edwin Brady
588a5b74cd Only record fields should be in a new namespace
Record name and constructor are in the outer namespace, fields in the
nested namepsace. Private names in the nested namespace is visible from
the outer namespace. Fixes #183

Also remove the 'nested' flag on INamespace, since it was only there for
records, and not really the right way to do things. The nested namespace
name is now given in the IRecord constructor (a front end might not want
to use a new namespace after all).
2020-03-18 22:48:19 +00:00
Edwin Brady
776abebba1
Merge pull request #227 from ska80/typedd-book/chapter13-14
Port code examples for chapters 13 and 14 from TypeDD book
2020-03-18 20:37:26 +00:00
Edwin Brady
c1bc4330fa Don't build run time case trees for Rig0 defs
They might match on runtime-erased things (which is okay, since they're
erased too!) and if we try building the tree, it'll report an error
incorrectly. Fixes #229
2020-03-18 20:09:11 +00:00
Edwin Brady
22febdf7ff Take environment into account in coverage check
We weren't using the surrounding environment for building the patterns
for an impossible case, so getting strange errors. Fixes #228
2020-03-18 14:05:01 +00:00
Kamil Shakirov
1704495f06 Port code examples for chapters 13 and 14 from TypeDD book 2020-03-13 09:50:22 +06:00
Edwin Brady
946881d56c Make sure we only insert 'Delay' at the top level
If we postpone unification problems, it's not necessarily at the top
level of a term, but then if we retry and find we need to insert a
'Delay' or 'Force' then it had better be at the top level or we'll get
an incorrect term. So, keep track of this in postponed constraints.
2020-03-12 14:58:06 +00:00
Edwin Brady
288a92424a Unifier mustn't resolve things which aren't holes
For example, delayed elaborators. If it resolves one, and it's not a
complete solution, we might end up with unsolved holes. Or - possibly
worse - we might end up with an error in a program that is silently
fixed rather than reported!

Fixes #223
2020-03-09 23:04:02 +00:00
Arnaud Bailly
3a98ce91ea cope with different number of :ok return values 2020-03-06 19:20:25 +01:00
Edwin Brady
9060b24f2f Move network test to chez test suite 2020-03-05 18:03:12 +00:00
Edwin Brady
1dd81ff10b Look under . for function name on lhs
Need this to rule out some ambiguous names. Fixes #204.
2020-03-05 11:22:48 +00:00
Edwin Brady
f38dd50b3f
Merge pull request #203 from m-bd/path-lookup
Add PATH lookup to find Chez Scheme
2020-03-05 10:17:33 +00:00
Edwin Brady
a5c356f998 Basic support for struct in FFI
Just in the Chez backend for now, and not allowing strings or functions
due to limitations of Chez.
2020-03-01 23:23:21 +00:00
Mounir Boudia
141c52ded7 Add PATH lookup to find Chez Scheme
On some systems "/usr/bin" and "/usr/local/bin" are not used.
If CHEZ env variable is not defined, lookup for chez in the PATH if
defined. Otherwise falls back to the old behaviour. (ie. lookup in
"/usr/bin" and "/usr/local/bin" as a last resort)
2020-02-27 23:47:54 +01:00
Edwin Brady
2a2a20849d Add default implicit arguments
These are part of the core QTT now, so any substitutions or dependencies
will be dealt with as they should.
2020-02-25 14:09:08 +00:00
Edwin Brady
57a14ff401 Coverage checker looks at 'impossible' clauses
These can give valuable information, but since they're not well typed,
we have to rebuild as close an approximation as we can before passing it
to the case tree compiler. We can do this in a type-directed way, but
ignoring whether any of the arguments are convertible, and not trying to
solve any of the implicits. If this fails, it doesn't use the impossible
case, otherwise it uses it to find the missing cases in the resulting
case tree.
2020-02-23 21:40:23 +00:00
Edwin Brady
11da440124 Ambiguity checking on locals in auto search
Fixes #160
2020-02-23 17:30:48 +00:00
Edwin Brady
654ab0cbd0 Look inside definitions during conversion
If two definitions are identical, with the same arguments, they should
convert, even if they have different names. Fixes #194
2020-02-23 15:58:14 +00:00
Edwin Brady
e126dcd28f Add --find-ipkg flag
This looks for an .ipkg file in a parent directory before loading the
given file, and loads it relative to the .ipkg's source directory, with
the options specified in the .ipkg.

The intention is to save all the editor modes having to do the same
thing, and especially makes it possible for the new vim mode to work
with ipkgs.
2020-02-22 23:25:02 +00:00
Edwin Brady
8158c617f6 Disambiguate data constuctor families
If the name is given (rather than, say, computed) update it so that it's
the data type name being defined - so ambiguities are resolved
immediately. Fixes #192
2020-02-22 19:32:22 +00:00
Edwin Brady
22a779bc88 Proof search on solved holes shows result
From the result of unification
2020-02-22 15:30:45 +00:00
Edwin Brady
fb49038c9f Don't automatically apply implicits in let
This means we can say 'let x = foo' and have foo not be applied to its
implicit arguments, meaning that 'x' can be instantiated at whatever
implicits it needs through the scope.
2020-02-16 16:33:17 +00:00
Edwin Brady
3fe5c78f86 Conversion checking of case blocks
This is a little bit of a hack, but is for the situation where a case
block arises from the same bit of source but with a different name,
which would happen when elaborating interfaces with cases in a method
signature. If it's the same function with the same scrutinee, it's
convertible.
Fixes #191
2020-02-13 18:26:37 +00:00
Edwin Brady
666373e9db Implement 'using' notation
See test idris2/basic035; implicitly binds an auto-implicit for
interfaces if no name is given, or an implicit argument if a name is
given.
2020-02-11 17:27:04 +00:00
Edwin Brady
413d09dad8 Unification tweak for getting lambda types
We've been generalising inferred function types to have multiplicity
RigW but sometimes (especially on lambdas) we need to infer the precise
type, so make a distinction.
This is pretty ugly, really. It would be better to be able to postpone
the choice until we know more, but it's not obvious to me how to achieve
that with the way unification is currently set up. The present way at
least works fine with code that doesn't use linearity, which is the
right default I think!
2020-02-09 17:05:22 +00:00
Edwin Brady
4fed357fb4 Allow type annotations on lets
Fixes #87
2020-02-01 12:17:54 +00:00
Edwin Brady
bb6cefc0a9 Added Data.IOArray
plus scheme primitives for runtime, via vectors
2020-01-30 17:04:33 +00:00
Edwin Brady
6f9cca6ce3 Change inference of function types in unification
Always infer a multiplicity of W. Since we can pass a linear function to
one which expects an unrestricted argument, this gives the more general
result if the multiplicity is otherwise unknown.
This makes things like 'maybe id (+) x y' type check again even in the
presence of an 'id' which is declared linear!
2020-01-27 17:54:21 +00:00
Edwin Brady
c725d37488 Add %unbound_implicits directive
This is the same as %auto_implicits in Idris 1, but with a more
appropriate name, because auto implicits are something else.
'%unbound_implicits off' turns off implicit forall bindings. See test
basic033 for an example.
2020-01-27 17:31:53 +00:00
Edwin Brady
3cb574102a Add idiom brackets 2020-01-26 17:24:25 +00:00
Edwin Brady
1da3af5b2a Add ! notation
In a small change from Idris 1, this lifts to the nearest binder or
block, so doesn't lift past an explicit "do" in particular. Blocks are:
- case branches
- if branches
- scope of local function definitions, or any binder
- do blocks
2020-01-26 16:52:25 +00:00
Edwin Brady
04e4ebf80e Better approach to erasure in pattern matching
It's a big patch, but the summary is that it's okay to use a pattern in
an erased position if either:

- the pattern can also be solved by unification (this is the same as
  'dot patterns' for matching on non-constructor forms)
- the argument position is detaggable w.r.t. non-erased arguments, which
  means we can tell which pattern it is without pattern matching

The second case, in particular, means we can still pattern match on
proof terms which turn out to be irrelevant, especially Refl.

Fixes #178
2020-01-21 18:47:43 +00:00
Edwin Brady
da293d1ce8 Check constructors are fully applied in case trees
This is necessary to build case trees correctly, and without this, we
can get mysterious and hard to debug run time errors!
2020-01-11 17:27:27 +00:00
Edwin Brady
7cde0a7255
Merge pull request #174 from chrrasmussen/fix-double-subtraction
Fix subtraction of Double in interpreter
2020-01-09 11:41:40 +00:00
Christian Rasmussen
a70c68da91 Add test for Double subtraction 2019-12-22 21:50:18 +01:00
Timmy Jose
1c1e2b16ca Reorder Scheme compilers order to pick Chez Scheme first.
This fixes the issue where some Scheme compiler like mit-scheme is
installed and that gets picked up first, leading to an infinite
loop in the tests.

Also see attached image in the PR.
2019-12-21 18:42:09 +05:30
Edwin Brady
663e1b8f69 Add uniqueSearch data type option
This changes the behaviour of 'auto' implicits so that by default they
return the first result, rather than checking for unique results. This
is consistent with Idris 1. However, we still want to check for
uniqueness somtimes (for example, with interface search, which should
reject overlapping results) so the 'uniqueSearch' option means that any
auto implicit search for the type should check uniqueness of results.

Fixes #169
2019-12-07 18:54:02 +00:00
lodi
76ff99d370 allow overriding racket/chicken paths through environment variables
This is to help Idris2 codegen the correct scripts on NixOS where
Racket and Chicken aren't installed in the standard locations, and
the /usr/bin/env trampoline is disabled at package build time.
This now matches the existing Chez behavior.

Also, fixed the test runner to restore the correct working directory
after a failed test, and fixed the top-level Makefile to allow the
IDRIS2_VERSION variable to be queried without building the project.
2019-10-28 22:44:16 -04:00
Edwin Brady
da1964ce3d
Merge pull request #134 from ohad/bugfix-#109
Add multiple-parameter test as idris/basic029
2019-10-25 14:05:45 +01:00
Edwin Brady
c458957bd6 Get correct namespace in parameters blocks
Fixes #132. When getting the names in the block, we need to return the
fully explicit name, because we can't assume they'll all be in the same
namespace as we can have namespaces inside parameters blocks.
2019-10-25 14:03:15 +01:00
Ohad Kammar
90927cd886 Add multiple parameter block to test suite 2019-10-24 00:06:57 +03:00
Arnaud Bailly
eedbf23f38 allow matching constants in with clauses fix #122 2019-10-15 21:52:44 +02:00
Edwin Brady
c6039e4fe5 Support callbacks in foreign calls to C
Currently Chez backend only
2019-09-29 17:25:26 +01:00
Edwin Brady
1a4f424259 Support UTF8 strings
When writing to ttc, need to take the length in bytes rather than the
length in characters. Also need to write to scheme in the appropriate
format for each scheme system.

While we're at it, Idris 1 supports unicode identifiers (although we
don't encourage it :)) so this allows any characeter >127 in an
identifier.
2019-09-28 14:08:23 +01:00