Commit Graph

255 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Edwin Brady
e1c6926da6 Store name directives as a map
They're global, and so we don't reset per file, so we might get
duplicates, so it's much quicker to store as a map even though we'd
expect few of them overall.
2020-02-01 18:06:35 +00:00
Edwin Brady
cf27bbed66 Small tweak to record updates
A bit more constraing solving in case it helps find the record type
2020-02-01 13:32:39 +00:00
Edwin Brady
f3cb5a8648 Delay record updates on type inference failure
Sometimes this'll need to be postponed since we need information from
elsewhere to know what the record type is (just like in ambiguity
resolution)
2020-02-01 12:57:45 +00:00
Edwin Brady
886b6aae7f Reset auto lazy/unbound implicits
These options are local to a file, so reset when building a module. Also
actually enable the %auto_lazy directive.
2020-01-31 18:23:38 +00:00
Edwin Brady
56b01f476b Temporarily disable a couple of unused things
The Chicken backend and reflection code are currently unused, and add to
memory usage and build time, so best leave them out for the moment.

They will be back! But probably best to wait until we can self host -
which hopefully won't be long - and we can take advantage of some of
the things Idris 2 does to compile quicker and using less space!
2020-01-27 19:17:02 +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
9cd040fcb4 Resolving ambiguity under IMustUnify
Need to use 'check' which expands ambiguous names, rather than
'checkImp' which does nothing. It won't insert any new dots since it
checks in expression context.
2020-01-25 13:23:56 +00:00
Edwin Brady
a26581f454 Use a data type for dotting reason
Then we can more safely match on it
2020-01-24 16:16:31 +00:00
Edwin Brady
118ea787c3 Add syntax for 'using' blocks 2020-01-24 15:21:16 +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
f81085cf67 Normalise goal on initialising proof search
It needs normalising anyway to get for determining arguments, so might
as well do it up front (it can save time later).
2020-01-18 23:37:20 +00:00
Edwin Brady
b8a8f0ef1b Some fixes in time logging code 2020-01-18 15:14:23 +00:00
Edwin Brady
6495d603d7 Add %unifyLog for debugging
Prints debugging logs while elaborating the argument
2020-01-15 09:49:41 +00:00
Edwin Brady
d619c09ba3 Remove unnecessary solveConstraints 2020-01-13 11:49:16 +00:00
Edwin Brady
fe74d6bb7c Add impossibility flag to Erased
This is to help coverage checking, for LHS clauses which are impossible,
so that we can build the complete case tree from the impossible clauses
too.
2020-01-12 20:06:02 +00: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
62a86db1d5 Fix build! 2020-01-11 23:08:30 +00:00
Edwin Brady
4ce469cc03 Name choice of holes
The names should give more of a hint as to where the holes were created.
Might help with #161.
2020-01-11 22:52:18 +00:00
Edwin Brady
9fe236d5b1 Allow expressions in %foreign directives
Rather than just raw Strings. They get evaluated immediately at the
point of elaboration, and this can be used to save repetition (e.g. of
shared library names) in declarations.
2019-12-30 21:10:41 +00:00
Edwin Brady
f2a26ecfbd Deal with interface constraints in method types
To build the top level method and interface record correctly, we need to
know where to put the implicit arguments, so invent names if they don't
have them already then we'll know where to put things accurately.
2019-12-29 20:36:08 +00:00
Edwin Brady
6ab4657573 Do delayed elaborators in order they were added
Earlier solutions may influence later ones. Probably we should be
cleverer still here, and keep trying while any delayed elaborators are
run successfully, because really the order shouldn't matter!
2019-12-29 15:42:33 +00:00
Edwin Brady
952abe7fc8 Deal with auto implicits when adding lambdas
We were only checking the type for implicit lambdas, so using lambdas in
functions with an auto implicit was giving a strange error.
2019-12-09 18:00:36 +00:00
Edwin Brady
c85ffd2c29 Return correct type on variadic application
In the case where the function type is not yet known, and there's a
postponed unification problem, we were returning the function type not
the result type.
--debug-elab-check ought to be extended to catch this sort of thing.
Fixes #168
2019-12-08 00:25:49 +00:00
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