Commit Graph

216 Commits

Author SHA1 Message Date
Edwin Brady
af9dc69c61 Add record tests from Blodwen 2019-06-24 12:44:34 +01:00
Edwin Brady
aebb8ddfde Need to update full names in metadata
We need to do this as we're building, not just on saving, because we
might immediately use it when searching for full definitions.
2019-06-24 09:51:02 +01:00
Edwin Brady
0a15c2cda1 Pay attention to visibility of names
Name lookup and search should ignore names which aren't visible (that
is, private names in another namespace)
2019-06-24 00:57:22 +01:00
Edwin Brady
67a43e0000 Check names are visible/public 2019-06-24 00:12:58 +01:00
Edwin Brady
40ea548a65 Cache whether a local is let bound, if we can
Since lookup up a binding can be expensive in a big environment, and we
only need to reduce it if it turns out to be a let, caching it can be a
noticeable win
2019-06-23 23:12:27 +01:00
Edwin Brady
9c902de5d1 Fix case tree compiler for coverage checking
We can't refine by a name in Rig0 because we can't assume it covers all
possibilities, so only refine by them at the end, at which point we
check that there's only one case left (otherwise we have to match on it,
which is not allowed for an erased thing)
2019-06-23 20:36:06 +01:00
Edwin Brady
9350122e1b filterM was quadratic time. Oops!
Some care is still needed with ! notation because it lifts out of the
branches in if blocks and it really shouldn't...
2019-06-23 16:04:32 +01:00
Edwin Brady
1a333a481b Process name directives from TTC 2019-06-23 12:52:37 +01:00
Edwin Brady
f77ef8154b No longer any need for NameRefs 2019-06-22 22:36:15 +01:00
Edwin Brady
2df399a03c Save definitions as Binary
Then on reloading, only decode the Binary when it's first looked up.
This is a huge win on loading because it's decoding the binary blob that
costs, rather than loading it!
2019-06-22 20:40:16 +01:00
Edwin Brady
7ba57cfc64 Store names in full in ttc
and resolve on reloading. This saves the time for loading the name map,
which can start to get big if there's lots of imports.
2019-06-22 16:09:43 +01:00
Edwin Brady
60837bd599 Add interface HasNames
This allows conversion between structures with explicit names vs
resolved names
2019-06-19 00:59:55 +01:00
Edwin Brady
c21918e1f5 Add TTC interface Binary
This will let us decode things later, so we're not required to decode
Binary data immediately on loading from a TTC
2019-06-18 22:02:52 +01:00
Edwin Brady
070869f387 Add EmptyFC as a constructor
This way we don't have to keep rebuilding it every time when decoding
Terms from binary
2019-06-18 21:03:20 +01:00
Edwin Brady
76e2bd30e6 Slightly simpler binary writing
Easier just to have one chunk, starting pretty big, and grow it and copy
content if necessary
2019-06-18 18:10:24 +01:00
Edwin Brady
318a6eeab9 Add arguments to NForce
If it gets stuck, it could have a stack of arguments and we can't just
throw them away!
2019-06-18 09:42:00 +01:00
Edwin Brady
ed2d88b87e Unelaboration of case blocks
This was identifying the old blodwen style name, also we need to store
patterns in ibcs after all if we want to see the unelaborated block
contents
2019-06-17 14:08:07 +01:00
Edwin Brady
2cdfac47b0 Look for case splits under As patterns 2019-06-17 13:46:54 +01:00
Edwin Brady
f1becb4ae0 Fix 'last chance' auto search
Need to record the solution as well as find it! Too much copying from
Blodwen without thinking here :)
2019-06-17 12:35:42 +01:00
Edwin Brady
6a72508e80 Eliminate cycles in auto search
This is important for, e.g. interfaces with parent constraints, so we
don't keep looping making the constraint bigger
2019-06-17 09:50:05 +01:00
Edwin Brady
8bc46c3438 Remove spurious assignment!
Left over from before pruneByType was implemented. Oops!
2019-06-16 23:23:57 +01:00
Edwin Brady
f5a5d01274 Turn lets to lambdas in hole environments
This works better when lifting lemmas, and ensures that the type of
everything will be shown and not normalised away
2019-06-16 23:10:32 +01:00
Edwin Brady
620ad8e706 Find linear bindings needs to know about As 2019-06-16 21:33:59 +01:00
Edwin Brady
ecb5cb1e40 Don't keep running delayed elaborators
Also fix a bug where the elaborator state wasn't updated on completing
the delayed elaborator, which could cause issues with implicitly bound
names in particular.
2019-06-16 20:48:31 +01:00
Edwin Brady
8d6b990157 No need to evaluate in 'instantiate'
Types are generated from the environment, and we only want to know how
many arguments there are
2019-06-16 15:24:52 +01:00
Edwin Brady
4bc87b4c72 Some TTC/Delay fixes
Need to run delayed elaborators before binding implicits, since there
might be some inside the delayed elaborator. Also reorganise TTC
implementations so they're all in one place.
2019-06-16 13:47:20 +01:00
Edwin Brady
dcae2c3386 Only write out names which are actually used
Rather than all the metavariables ever created, just the ones which end
up in terms (e.g. after inlining)
2019-06-15 18:28:41 +01:00
Edwin Brady
1be12c7f72 Block reduction of private/export names 2019-06-15 16:10:01 +01:00
Edwin Brady
ed43fd49b9 Save FC so that metadata works 2019-06-15 13:28:27 +01:00
Edwin Brady
a7bf075c94 Get GlobalHint flag right
'True' means a default hint, which is only used if all else fails (and
is only really intended to get default Integer)
2019-06-15 12:42:35 +01:00
Edwin Brady
46c29c2ee4 Tweak rules for usableLocal in search
Needs to be allowed to search for things indexed by pattern variables,
which are not really holes in the same sense, or it might not find
things in types.

(Aside: we're currently implicitly binding failed searches in types,
which is, I think, wrong... better to report the failure)
2019-06-14 19:00:16 +01:00
Edwin Brady
8f386011b1 Defer erasure/run-time case trees
Don't build these until we've completed the whole clause (that is, don't
do it if we're inside a case block) because we might need to collect
more information to complete checking the case block. e.g. there may be
constraints inside the case block that are resolved outside.
2019-06-14 18:35:31 +01:00
Edwin Brady
2f7aa69f41 Remove AppInfo
It's just in the way, we don't use it for anything, and everything we
might get out of it we're already getting out of the type. Revisit later
if it turns out to be worth it.
2019-06-13 19:33:10 +01:00
Edwin Brady
2c1c86639a Update makefiles and paths
We can now build and install the prelude, and hello world has
successfully compiled to chez
2019-06-13 16:53:16 +01:00
Edwin Brady
772b098de0 The Prelude type checks! 2019-06-13 13:23:21 +01:00
Edwin Brady
2374f23320 Add default alternatives 2019-06-11 13:52:49 +01:00
Edwin Brady
07229bdb5e Add first Idris2 tests 2019-06-11 11:54:47 +01:00
Edwin Brady
94cc2a0d4c Store type search hints separately
If we store them on the type constructor, we're required to have the
construction available, which might not be the case when reloading ttcs,
because we load and process modules *before* things they import.
2019-06-10 16:11:32 +01:00
Edwin Brady
803867006b Add some missing files! 2019-06-09 23:14:27 +01:00
Edwin Brady
5a3aa3b13c Some fixes for as patterns, add them implicitly
Much of the effort in renaming is to make types of holes display more
nicely!
2019-06-09 23:12:11 +01:00
Edwin Brady
146c301f6c Change main program to be Idris2
With the --yaffle flag, you get the old behaviour which is to invoke the
checker for the core theory (and all the tests are updated appropriately
for this).
2019-06-09 11:58:29 +01:00
Edwin Brady
9d2067e9a8 Add command line option to invoke yaffle 2019-06-08 11:02:50 +01:00
Edwin Brady
c6a7050d39 Added Idris.Main 2019-06-07 11:29:29 +01:00
Edwin Brady
2afad1f13c Add package files 2019-06-07 11:14:45 +01:00
Edwin Brady
b9e67db95d Add REPL 2019-06-07 11:08:21 +01:00
Edwin Brady
c420082a43 Add Scheme back ends from Blodwen 2019-06-06 18:33:50 +01:00
Edwin Brady
8132378b04 Add Compiler.Common
This is generic compiler infrastructure (mainly finding all the names
used from a root expression)
2019-06-06 18:13:25 +01:00
Edwin Brady
18221f8f2d Add inlining for CExps 2019-06-06 09:51:30 +01:00
Edwin Brady
169a958105 Compiling to CExp 2019-06-05 21:25:03 +01:00
Edwin Brady
bf67f5c87c Record mutual type definitions
Also add some tests for totality checker
2019-06-05 17:28:55 +01:00
Edwin Brady
95cc48eeb6 Add termination checking
Still to do: mutual data definitions and proper testing
2019-06-05 15:59:35 +01:00
Edwin Brady
2c6202879e Calculate missing cases via coverage checker 2019-06-02 23:43:21 +01:00
Edwin Brady
1f52530313 Implement 'impossible' 2019-06-02 21:21:07 +01:00
Edwin Brady
f5556a1a9d Add Core.Coverage
Little of the recently added bits are wired up yet, but it'll all start
coming together soon.
2019-06-02 20:03:41 +01:00
Edwin Brady
bdc38d438c Add CompileExpr 2019-06-02 17:54:55 +01:00
Edwin Brady
5c2d78e893 More of the Idris machinery
ModTree and ProcessIdr
2019-06-02 17:24:39 +01:00
Edwin Brady
8302fb08a7 Bring in more bits of IDE mode 2019-06-02 15:38:39 +01:00
Edwin Brady
d6e637b2c5 Fix structural difference check in search
Now it successfully finds zipWith too
2019-06-02 15:16:54 +01:00
Edwin Brady
b41bd48970 Add MakeLemma 2019-06-02 14:41:21 +01:00
Edwin Brady
109dcf08f9 Add definition generation 2019-06-02 14:28:26 +01:00
Edwin Brady
af79e57ae2 Store number of locals in holes
This gives useful information for expression search, because we can add
lambdas while we're still building the environment, and start looking at
locals after that.
2019-06-02 01:23:01 +01:00
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
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
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