Commit Graph

524 Commits

Author SHA1 Message Date
Edwin Brady
8f583ca900
Merge pull request #189 from chrrasmussen/fix-ide-mode-backwards-compatibility
Fix IDE Mode for Atom
2020-02-27 10:38:36 +00:00
Edwin Brady
580bc6345e
Merge pull request #197 from ohad/parser-port
Bring `src/Text/Parser` and its dependencies closer to idris2
2020-02-27 10:37:38 +00: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
2967e9011f Add implementation ... using syntax
It's in the tutorial, and allows named implementations to use specific
parent named implementations.
2020-02-25 21:29:39 +00:00
Edwin Brady
61578a84b6 default is a keyword now 2020-02-25 14:09:33 +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
ff6fd4668b
Merge pull request #195 from ohad/default-totality
Add support for `%default [total | covering | partial]` directive
2020-02-25 14:08:35 +00:00
Edwin Brady
c862199dc2 Add updating version of makeLemma
<LocalLeader>l in the vim mode
2020-02-23 23:30:18 +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
Ohad Kammar
0ba11f1781 Undo changes, as not compatible with idris1 (oops):
* Implicit arguments on interface assumptions
* Removed unnecessary explication of an implicit arg
2020-02-23 19:26:00 +00:00
Ohad Kammar
a33095e559 Bring src/Text/Parser and its dependencies closer to idris2
This includes:

* Removing `%access` directives and inlining their visibility modifiers
* Fixing irrelevance annotations
* Including some standard libraries

The result is still not idris2 ready:

1. Incompatibility with the new Laziness mechanism, as it's missing
   some previous laziness/codata bindings

2. Some standard library functions moved around, and are now found in
   `Data.Nat`, that doesn't exist in Idris1
2020-02-23 18:58:44 +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
6d05627186 Change case multiplicity rule
IF we're in Rig0, need to check the case at Rig0, because we might want
to split on erased values and it's safe in Rig0
2020-02-23 16:55:19 +00:00
Ohad Kammar
9b8d476b4a Merge branch 'master' of github.com:edwinb/Idris2 into default-totality 2020-02-23 16:49:52 +00:00
Ohad Kammar
70aa4754b6 Add *stub* support for %default totality annotations
Since the totality checker isn't plugged in yet, these do nothing
functionally, but they do add appropriate totality annotations all the
way up to the internal `TT` representation.

Design choices:

1. default totality annotations are session-local, so should be reset
   between files.

2. the default default is `PartialOK`.

3. we won't annotate a definition with `PartialOK` unless the user
   inserts one themselves, relying on the previous point (2).
2020-02-23 16:46:21 +00:00
Ohad Kammar
9da96dd586 Simplify the definition of processFnOpt
There's no need to split into cases for the totality annotations, as
they now use the same representation in the AST as in `TT`.
2020-02-23 16:44:23 +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
Ohad Kammar
b7ba1a9301 Decouple totality annotations from IFnOpt using the existing TotalReq value
This requires moving `TotalReq` into `src/Core/TT.idr`.
2020-02-23 15:18:10 +00:00
Edwin Brady
65fe430a91 Remove -S flag from call to env
This isn't recognised on all systems, and I don't think it's needed (?)
Fixes #175
2020-02-23 12:24:29 +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
3bb5002dba Record whether a definition originated from a hole 2020-02-22 15:04:35 +00:00
Edwin Brady
f2a1934508 Save holes to ttc even if solved by unification
Fixes #108
Fixes #126
If solved, they don't get rendered the same way as holes with ':t' but
you see their full type. This should probably be changed.
2020-02-22 14:18:00 +00:00
Edwin Brady
6c0747c900 Reorganise implicit binding
This should be done at the surface language level only, not during
elaboration. This fixes #107
2020-02-22 12:52:40 +00:00
Edwin Brady
17694ab445 Updating versions of REPL editing commands
This gives us a cheap way to write editor interaction modes via idris2
--client (especially, this is how the vim mode works).
2020-02-19 13:22:59 +01:00
Edwin Brady
041e770ba4 Add --client
This is mostly as an easy way for editors to query Idris without having
to implement the whole IDE protocol!
2020-02-18 19:03:33 +01: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
dbb336acef Don't solve constraints before ambiguity
It doesn't achieve anything useful, and can be confusing because it
means behaviour is different for names where ambiguity is pruned by type
vs names where it isn't.
2020-02-15 15:03:59 +00:00
Edwin Brady
7e9c6e29e0 Ignore private names in ambiguity resolution 2020-02-15 14:25:47 +00:00
Edwin Brady
1cc6cd31b2 Fix 'import public'
Reloading is about the visibility flag, not the re-export flag
2020-02-15 14:08:48 +00:00
Edwin Brady
813148b52d Let and linearity again
If a let binding doesn't elaborate with a 'precise' inference, revert to
generalising. I still don't like this - we really need to be able to
postpone choice of multiplicities during unification. But we can't, yet,
so here we go.
2020-02-13 19:05:34 +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
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
4ccddbac4a Don't generalise to RigW on let types
This is just as ugly as the similar hack for lambdas in 413d09da, but
necessary to allow let binding of linear functions.
2020-02-11 17:54:11 +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
a9db2b6754 Fix hash calculation
This was resetting the current hash value so not calculating an
interface hash correctly, so sometimes not rebuilding when necessary.
2020-02-10 14:22:12 +00:00
Edwin Brady
f9a3ed2e0c Don't search locals when doing defaulthints
If we do, we might solve something we shouldn't because we're not
checking determining arguments. In 'defaults' mode, we should *only*
apply default hints - we'll go back to the locals in a final pass.
2020-02-09 22:44:04 +00:00
Edwin Brady
fa190ab1a9 Fix import/import public
Only make a note that a module is imported when processing the source
file that imports it. We were accidentally reexporting a lot!
2020-02-09 21:45:01 +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
6cda854ceb Change multiplicity when inferring ->
It should only be RigW if it wasn't known to be Rig0 already
2020-02-02 15:51:49 +00:00
Edwin Brady
e5c70195da Count argument position in parameter blocks
We need to know where we are so that we know if we're at an
erasable/detaggable argument position
2020-02-01 19:51:56 +00:00