Commit Graph

145 Commits

Author SHA1 Message Date
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
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
59b66d6134 Add prettyName
This is to display names in a user friendly way, especially case and
with block names
2020-03-18 19:33:19 +00:00
Edwin Brady
fbff80545d Add coverage006 test 2020-03-18 14:39:59 +00:00
Edwin Brady
8db29f5b35 Add --no-banner to test 2020-03-17 21:34:16 +00:00
Edwin Brady
102fb7fdb6 Coverage checker improvement
Check that none of the generated missing cases match explicitly given
clauses, which might happen if there's some overlaps in the clauses or
if there's some matching on implicits. Ignore erased argument positions
when checking the match.
2020-03-17 21:12:21 +00: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
9229cdbf1f Fix order of metavariable substitution
Need to substitute the one applied to most things, or it won't want to
substitute at all. Fixes #226
2020-03-10 19:39:36 +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
Edwin Brady
34044597c0
Merge pull request #213 from ska80/prelude/getchar-putchar
Add getChar, putChar and putCharLn to prelude
2020-03-07 14:15:22 +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
Kamil Shakirov
c8c0c5fb49 Add getChar, putChar and putCharLn to prelude 2020-03-05 14:55:20 +06:00
Edwin Brady
1bb028ae47 Update proof tutorial for Idris 2 2020-02-26 12:33:01 +00:00
Edwin Brady
16ae7994e7 More documentation refreshing 2020-02-25 22:18:02 +00: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
2da8da8aa9 Add missing test file 2020-02-23 22:20:11 +00:00
Edwin Brady
cd972143a5 Also check unique locals inside pairs
The error message doesn't propagate nicely here yet, but it should still
report failure to resolve the search
2020-02-23 17:44:18 +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
5c86552e56 Parse primitive types as identifiers
This way we can use them as parts of namespaces - they don't need to be
reserved keywords, just reserved names. Fixes #111
2020-02-22 18:36:46 +00:00
Edwin Brady
03bdc3145c Type of generated top level methods
Pass through the types of the interface parameters to the top level
method types, because there might be information in there that we can't
otherwise infer. Fixes #188
2020-02-22 17:38:13 +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
84faedba50 Tweak expression search heuristic
Search locals left to right, so that they are used as arguments in the
same order by default in recursive calls.
2020-02-15 23:24:00 +00:00
Edwin Brady
14e9872f07 Don't show MN names in hole contexts
This prevents display of shadowed names from case blocks/where clauses
that are now unusable. It does mean that constraint arguments aren't
displayed, unless given an explicit name - this may not be good, since
we might want to know which constraints are in scope, so it may yet need
a little tweaking.
2020-02-15 22:33:13 +00:00
Edwin Brady
6267231649 Cut down default search depth
If it's not going to find an auto implicit by then, it never will, and
we'll just take ages to get an error
2020-02-13 18:23:40 +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
9fd2e428ad Check import hashes before a full parse
This needed a bit of reorganisation, but it speeds up checking if a
module doesn't need rebuilding due to the import interfaces not
changing. Also it means that the "Type checking foo.idr" message is
displayed before parsing rather than after, which is probably better.
2020-02-10 15:47:19 +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
722131f7d0 Simpler implementation of 'case'
Now only abstracts over the environment once and deals with 'where'
clauses by rewriting the nested name with the rearranged environment. As
a result, it interacts far better with local definitions (i.e. where
blocks).
2020-02-09 13:46:58 +00:00
Edwin Brady
4fed357fb4 Allow type annotations on lets
Fixes #87
2020-02-01 12:17:54 +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
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
af9e920d74 Merge branch 'linearity-clean' of https://github.com/ohad/Idris2 into ohad-linearity-clean 2020-01-19 16:56:13 +00:00
Edwin Brady
ea8c22135c
Merge pull request #156 from clayrat/misc-fixes
Misc fixes and additions
2020-01-19 16:48:47 +00:00
Edwin Brady
a275b57a81
Merge pull request #154 from abailly/better-ide-mode
Improve IDE mode to provide basic Emacs mode interaction
2020-01-19 16:47:18 +00:00
Alex Gryzlov
ce15b48a78 Merge remote-tracking branch 'upstream/master' into misc-fixes 2020-01-15 22:52:38 +01:00
Edwin Brady
751fd1f36a Experiment with hole name display
If unelaborating a term that's just a hole, show the scope it was
created in too, to help with error messages
2020-01-11 23:34:44 +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
Arnaud Bailly
432cc7ca5c Merge branch 'master' of https://github.com/edwinb/Idris2 into better-ide-mode 2020-01-11 09:45:39 +01:00
Ohad Kammar
971bfc5bbd Update prelude line numbers in a test 2020-01-09 13:06:39 +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
Edwin Brady
df3f8b73f8 Further tweak to linearity rules
When we check a scope in RigW, need to mark all linear things outside
that scope as irrelevant within the scope (since the scope may be used
multiple times).
2019-12-29 15:21:08 +00:00
Christian Rasmussen
a70c68da91 Add test for Double subtraction 2019-12-22 21:50:18 +01:00