Commit Graph

107 Commits

Author SHA1 Message Date
Edwin Brady
bf70aa07d2 First attempt at expression search
Not quite there yet because we're not saving all the information about
holes in TTCs but the basics work
2019-06-01 22:34:59 +01:00
Edwin Brady
ae28f1b1f2 Add CaseSplit
Adapted from Blodwen version
2019-06-01 19:05:02 +01:00
Edwin Brady
b1f7863830 Add Implementation and Interface
It turns out we need a new kind of map, mapping possibly ambiguous names
to values. This is what 'Context' does but we can only have one of them
because it resolves names to a position in an array and it'd be
confusing to have more than one index per name.
2019-06-01 18:13:19 +01:00
Edwin Brady
d82f6c5080 Add errors, REPLCommon now builds 2019-06-01 15:53:16 +01:00
Edwin Brady
2e2622c38b Add more of the high level stuff 2019-06-01 15:05:04 +01:00
Edwin Brady
a7d7785a0a Added Idris.Socket
In preparation for REPL and IDE mode
2019-06-01 14:13:28 +01:00
Edwin Brady
5bbab03e38 Added Idris.Desugar
Mostly adapted from Blodwen, also added necessary bits to the context
such as name directives and hiding.
2019-06-01 14:11:21 +01:00
Edwin Brady
67cbf05b4c Add parser for high level syntax
Almost entirely unchanged from Blodwen
2019-05-31 18:50:07 +01:00
Edwin Brady
a3bf2e3aa9 Start on the high level syntax
Copied and adapted Idris.Syntax from Blodwen, updated to cope with new
core.
2019-05-31 18:48:04 +01:00
Edwin Brady
a05c656d76 Record editing metadata and interface hashes 2019-05-31 11:42:11 +01:00
Edwin Brady
2b38ce0188 Add Metadata type
Metadata is now propagated through the elaborator, although we're not
using it yet
2019-05-31 05:52:54 +01:00
Edwin Brady
6c88bfec7a Elaborate 'with' blocks 2019-05-29 11:57:07 +01:00
Edwin Brady
a59a104230 Implement 'rewrite' expressions
Mostly direct from Blodwen (some minor modifications to deal with new
way of going into a new scope in the elaborator as well as the usual
bits dealing with name lookup and Glued terms)
2019-05-27 12:15:37 +01:00
Edwin Brady
7cc37d28b3 Add (dependent) record update
This is pretty much straight from Blodwen
2019-05-27 10:56:13 +01:00
Edwin Brady
22a5286ed9 Added record declarations
Also, since it could need it when building types, added auto implicit
binding (so no need for $ everywhere in the tests from now on...)
2019-05-26 23:51:20 +01:00
Edwin Brady
c4d7e18742 Extend unification so that Functors work
Need to identify invertible (or cancellable) holes so that we can unify
e.g. ?f Nat with List Nat and get f = List.
2019-05-26 18:41:48 +01:00
Edwin Brady
628a7bde0f Improve auto search to support interfaces
Parser now allows options on data types and functions, and elaborator
processes options so we can set up interfaces
2019-05-26 14:28:38 +01:00
Edwin Brady
3e3c224bcb Move some tests around
Add a 'search' category
2019-05-26 11:34:02 +01:00
Edwin Brady
18e0cabc26 Save hints to TTC files
And process them on loading. We record that hints need saving out when
adding them, and clear that list unless we happen to be reexporting the
thing we've just read (import public).
2019-05-25 23:31:47 +01:00
Edwin Brady
54d4d5a8ed Implement auto implicits 2019-05-25 22:13:38 +01:00
Edwin Brady
c65285a1f6 Check pattern variables don't unify with things
This is bad because it means a pattern variable isn't actually a
variable, but rather has a specific value!
2019-05-25 20:18:43 +01:00
Edwin Brady
6c7f13d128 Implement dot patterns
Like Idris 1, these are implicitly added on encountering a repeated name
or a non-constructor application. Unlike Idris 1 (and Blodwen) they are
checking by unification rather than matching (which means in particular
that function argument names can't be bound in dot patterns) which is
slightly less expressive, but better overall because matching is
potentially more error prone.
2019-05-25 18:39:21 +01:00
Edwin Brady
c75569c255 Implement laziness
Slight change of plan: instead of having special names, add Lazy, Inf,
Delay and Force and keywords and elaborate them specially.
Correspondingly, add DelayCase for case trees. Given that implicit
laziness is important, it seems better to do it this way than constantly
check whether the name we're working with is important.

This turns out to make implicit laziness much easier, because the
unifier can flag whether it had to go under a 'Delayed' to succeed, and
report that back to the elaborator which can then insert the necessary
coercion.
2019-05-22 19:42:43 +01:00
Edwin Brady
9f4ca9e67f Add pruneByType
This shortcuts ambiguity checking by only keeping the things which have
the target type. Given a set of ambiguous applications, the rules are:

- keep any which return the expected target type (a concrete match), or
  a polymorphic type (a possible match)
- if there are any concrete matches, drop any possible match which has
  the '%allow_overloads' flag set (in practice this will be interface
  methods, but other things can be flagged).
- if there ar eno matches, keep everything so that the error messages
  show everything that went wrong.
2019-05-21 12:11:55 +01:00
Edwin Brady
c2e1b85143 Let's not use exceptions for control flow... 2019-05-20 19:05:28 +01:00
Edwin Brady
6385cb6e0f A bit more on performance
Most notably, when elaborating deferring argument, if the hole
standing for the argument is still a hole, fill it in directly rather
than going via unification. This prevents some needless evaluation.
2019-05-20 18:41:08 +01:00
Edwin Brady
11a72dc953 Some small tweaks
These are attempts to allocate slightly less memory. They don't achieve
much, but also don't do any harm...
2019-05-20 13:36:32 +01:00
Edwin Brady
0ac539fdc2 Substitute a whole environment at once 2019-05-19 23:41:02 +01:00
Edwin Brady
871ca6603c Move options out of Core and into Defs
This is quite a performance win, because there's less thunking (and I
imagine more scope for inlining?)
2019-05-19 23:25:35 +01:00
Edwin Brady
f95205b8b9 Some small performances improvements
The biggest one being that logging wasn't taking the String as a lazy
argument!
2019-05-19 23:05:21 +01:00
Edwin Brady
d256dbf5ec Add a test for non linear LHS 2019-05-19 20:30:27 +01:00
Edwin Brady
8081b0374a First attempt at linearity checking pass
This slows things down a bit because to find the holes and give them the
right multiplicities, we need to normalise all the arguments which might
have been metavariables. Maybe we should skip this if we're not using
anything linear, for efficiency?

As patterns are handled by deciding which side of the as is considered
'used'. In case blocks, that should be the variable name, but in general
it should be the pattern, so IAs now has a flag to say which one.
2019-05-19 20:24:14 +01:00
Edwin Brady
9bd063bbd5 Check holes are solved after elaboration
Need to record which holes are still to be solved (not counting
elaborations where there are user defined holes) and check at the end
that they are now solved.
2019-05-18 19:08:43 +01:00
Edwin Brady
1a84fde2a4 Added named holes
Unlike in blodwen, it is okay for a named hole to be solved by
unification. (Is this the right choice?)
2019-05-18 11:47:57 +01:00
Edwin Brady
5383bd89be Fix interaction between as patterns and case
There was a check on evaluating lets which was in Blodwen but I hadn't
added to the normaliser yet! Also, normalisation needs to reduce as
patterns for unification, but not when reducing finished LHS and
argument terms. This is a bit of a hack (but then, so is the
implementation of as patterns in general...).

So, when we're checking a nested expression, we have the as pattern as a
let bound variable (so that it has the necessary computational force)
but when we compile we just pass it as an ordinary argument, then it
gets the desired behaviour in case trees.
2019-05-17 18:47:20 +01:00
Edwin Brady
ea0de3d499 Initial implementation of 'case' blocks
It's not quite there yet, though, because the treatment of 'as' patterns
isn't quite right and the slightly hacky approach we're taking might not
be the best. Rethinking now...
2019-05-17 13:52:09 +01:00
Edwin Brady
c01fb4a555 Look out for cycles in implicits when normalising
This is not quite an occurs check (there's no guarantee anyone will ask
for normalisation after all) but it catches the error which will result
if there's a cyclic metavariable solution.

My plan is to implement the occurs check by going through all the
metavariables at the end of elaboration of an expression, so that we
don't do too much work checking half-finished solutions.
2019-05-15 17:50:40 +01:00
Edwin Brady
984c3ff70d Implement local function definitions
Changed nested names (and case blocks) to store the resolved name as the
outer name, rather than the unresolved name, otherwise we'll have issues
when loading from TTC
2019-05-13 00:44:28 +01:00
Edwin Brady
8d6d0c6847 Add NestedNames argument throughout elaborator
This is for tracking locally defined names, so that we can expand their
applications to the full globally lifted name. At the moment, they don't
do anything, but since it's a change throughout the elaborator it
probably deserves its own commit.
2019-05-12 19:43:01 +01:00
Edwin Brady
83dc0b0e6d Add simple let bindings 2019-05-12 19:04:31 +01:00
Edwin Brady
9baf180127 Clear delayed holes on failure 2019-05-12 16:32:56 +01:00
Edwin Brady
14f717aa33 Add test for failed delayed elaborator 2019-05-12 16:03:04 +01:00
Edwin Brady
2536b03e84 Don't allow nested delays
This makes the rules for ambiguous names a lot more restrictive (but I
think that's probably good...)
2019-05-12 15:29:08 +01:00
Edwin Brady
f3c31f3089 Give correct multiplicity count to arguments 2019-05-12 14:24:24 +01:00
Edwin Brady
6c00349274 And again... 2019-05-11 22:26:08 +01:00
Edwin Brady
905820efed Add missing file 2019-05-11 22:25:35 +01:00
Edwin Brady
eaff52a6e1 Use updated NF for delayed elaborators
Since the NF might refer to hole names, and those hole names might be
possible to evaluate now, we'll need to recalculate the expected type's
normal form before rerunning the delayed elaborator
2019-05-11 22:23:50 +01:00
Edwin Brady
43d323f685 First go at ambiguous name resolution
Works by running all possible elaborators and checking that exactly one
succeeds. Still to do: pruning the list of elaborators by target type,
dealing with 'UniqueDefault', checking that delaying on failure works as
it should.
2019-05-11 20:50:51 +01:00
Edwin Brady
46213a903c Store resolved ids in pattern names
It's only for keeping them unique, so this is both more efficient, and
means we can safely write them out using their resolved ids in the name
map
2019-05-11 13:00:12 +01:00
Edwin Brady
42f2d1c729 Expand ambiguous names
This has exposed an issue with resolved name indexes when reading from
ttc, which will be addressed shortly...
2019-05-11 12:19:39 +01:00