Commit Graph

43 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
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
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
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
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
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
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
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
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
Edwin Brady
a2ce8d0b7d Add as patterns
When we encounter them, not that they're a binding as normal, but also
record the thing they expand to. Then bind as a PLet, and convert that
to a Let on the RHS so it has computational force. The case tree
compiler knows about as patterns, so they get compiled to use the
appropriate name on the rhs (rather than a let).
2019-05-09 16:48:09 +01:00
Edwin Brady
411b8ccc07 Support eta in unification
Also added (necessarily) a rule for lambdas
2019-05-07 15:06:00 +01:00
Edwin Brady
ef36ea1752 Add TTImp.Unelab
This unelaborates things we don't even elaborate yet :). But we'll get
there...
2019-05-06 17:33:08 +01:00
Edwin Brady
29a41ed975 Initial implementation of auto implicit search
This only searches for lambdas and locals so far, and doesn't take into
account that it shouldn't search for holes, but it does set up the basic
mechanism.
2019-04-27 20:18:53 +01:00
Edwin Brady
6d473014fd Add simple REPL for TTImp 2019-04-26 10:16:23 +01:00
Edwin Brady
e592f548d1 Add timing logs
Just to allow tracking how long individual parts of processing a file
take!
2019-04-25 23:43:19 +01:00
Edwin Brady
762f6010dd Basic TTC saving and loading now works
Only save the parts of terms and definitions which are needed for
typechecking and evaluation (so, for example, we don't need types for
machine generated metavariables, don't need types on lambdas, etc).
2019-04-25 14:46:36 +01:00
Edwin Brady
a48d90f821 More progress on TTCs
Added Core.Directory (more or less directly from Blodwen) and now
writing out TTCs from the test Main, but it's still not writing out
definitions because we're not yet making a note of the names which need
saving (this will be the defined names and any holes introduced).

Also it's clear from logging that holes/guess/constraints aren't being
cleared so this needs to be fixed next.
2019-04-21 23:20:10 +01:00
Edwin Brady
cd958bd304 Remove 'Case' from Term structure
It seems that this isn't going to buy us enough to be worth the
complications of compiling case trees, dealing with 'with' etc.
2019-04-19 20:10:55 +01:00
Edwin Brady
c41ab9778f Progress towards pattern matching
Checking IBindVar and IBindHere, and first check of left hand side with
implicitly bound pattern variables.
2019-04-18 14:51:04 +01:00
Edwin Brady
e2594e9c80 Make a start on TTC reading/writing 2019-04-07 21:12:04 +01:00
Edwin Brady
56c0ec5324 Implement inferLambda
This checks lambdas where the type isn't immediately a pi binder. First
normalises, if that doesn't work, just guesses and unifies with the
expected type.
2019-04-07 17:16:44 +01:00
Edwin Brady
b8595eef8b Fill in some holes
The 'case' case of mkLocals, and looking up types of primitive constants
2019-04-07 14:51:50 +01:00
Edwin Brady
968b48c96e Some optimisations
Hole list represented as a map now for quicker deletion of solved holes.
Unification returns whether it solved any holes as part of its result,
so we know if it's worth going back to solve constraints if progress has
been made.
2019-04-07 11:50:36 +01:00
Edwin Brady
3cd09bb6a8 Unification infrastructure all done
Can instantiate metavariables, although there's a lot of cases still to
deal with
2019-04-06 13:53:59 +01:00
Edwin Brady
6174acc52a Progress on elaborator
Changed 'check' so that it returns the type as a 'Glued', which is a
pair of a term and its normalised form (or, more accurately, the process
to generate each in Core). Sometimes the elaborator needs Term,
sometimes in needs NF; this way we can return both but only actually
generate it when its needed.

So far, mostly done applications, binders and variables. Unification is
still to do.
2019-03-23 18:13:49 +04:00
Edwin Brady
547eea953c A bit of reorganisation
Better to have the elaborator across multiple files, for ease of
navigation. Also abandon the idea of local unification variables -
we'll keep them global, and try let binding them on leaving a scope.
2019-03-18 16:25:53 +00:00
Edwin Brady
7d672407c8 Start on UnifyState
Also removed 'MV' as a special name type, and added a Meta constructor
in TT which is applied to exactly the right number of arguments for the
environment the meta was constructed in.

It's possible the local unification UCtxt may be more trouble than it's
worth! Instead perhaps we can try let binding unification solutions where
possible on leaving the scope in which they're introduced.
2019-03-17 20:43:51 +00:00
Edwin Brady
57f1fb77c3 Added 'quick' unify
Unification based only on constructor arguments and matching - anything
else fails. Idea is to solve 'easy' local unification problems quickly,
without having to create a global metavar applied to the current context.
2019-03-17 13:34:22 +00:00
Edwin Brady
23051a55de Add Weaken interface, to start evaluator 2019-03-10 22:00:10 +00:00
Edwin Brady
0f8d337b27 Add a main program which processes a source file 2019-03-10 18:20:26 +00:00
Edwin Brady
992d8dd0f9 Added parser for most basic terms
Just variables, binders, applications, and basic declarations (data,
type and function definitions)
2019-03-10 17:56:08 +00:00
Edwin Brady
e03a2ba4b5 Added context for global names, store in an array 2019-03-10 15:14:38 +00:00
Edwin Brady
77e634cd33 Add specialised maps for Int and Name
The repetition is unfortunate, but worth it for avoiding the overhead of
passing an Ord dictionary around
2019-03-07 23:29:03 +00:00
Edwin Brady
082bc5cd54 Initial structure
TT types and values, some text manipulation, basics of Core
2019-03-07 23:04:55 +00:00