Commit Graph

695 Commits

Author SHA1 Message Date
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
625027f278 Add nub to Data.List 2020-02-09 21:45:36 +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
Edwin Brady
8227859760 Add System.Directory
Currently supports creating and changing directories. Support for
reading contents of directories still missing.
2020-02-01 18:43:28 +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
8d8d281fb4 Lift ! out of 'let' in do blocks 2020-02-01 13:54:10 +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
6f4fa7ade9 More Data.List functions 2020-02-01 13:32:30 +00:00
Edwin Brady
0612bbc1ca Lift ! notation out of record updates
It's not a block, so should be lifted
2020-02-01 13:05:11 +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
7d47c08140 Add Data.List.isPrefix 2020-02-01 12:57:14 +00:00
Edwin Brady
960ad42732 Add System.Info
Gets the OS info from the host compiler, which we'll need to be careful
with when bootstrapping (since maybe we'll distribute generated chez or
racket as a starting point for bootstrapping...)
2020-02-01 12:32:42 +00:00
Edwin Brady
4fed357fb4 Allow type annotations on lets
Fixes #87
2020-02-01 12:17:54 +00:00
Edwin Brady
284a3ded69 Add strIndex and strTail 2020-01-31 23:06:08 +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
b1c37b00ca Support hex literals in the parser 2020-01-31 18:15:19 +00:00
Edwin Brady
2465e5a149 Some buffer updates
Initialising buffers from files, error checking on creation, resizing.
2020-01-31 16:49:31 +00:00
Edwin Brady
e69c1529d9 Bitwise operators 2020-01-31 16:25:19 +00:00
Edwin Brady
854e39936e Some Data.Buffer bits
Need to know length of strings in bytes sometimes, not just characters,
to check we have enough space.
Also add copyData
2020-01-30 18:36:59 +00:00
Edwin Brady
0cb446dd31 Only use version tag in display
Not in generating install directories, otherwise we end up with loads of
new directories for every patch and the purpose is to make it easy to
see which version you're working with.
2020-01-30 18:25:18 +00:00
Edwin Brady
bb6cefc0a9 Added Data.IOArray
plus scheme primitives for runtime, via vectors
2020-01-30 17:04:33 +00:00
Edwin Brady
802dee2192 Fix ! notation on ifs
It wasn't lifting out things in the expression to be tested (via
desugarB).
2020-01-30 14:38:28 +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
6f9cca6ce3 Change inference of function types in unification
Always infer a multiplicity of W. Since we can pass a linear function to
one which expects an unrestricted argument, this gives the more general
result if the multiplicity is otherwise unknown.
This makes things like 'maybe id (+) x y' type check again even in the
presence of an 'id' which is declared linear!
2020-01-27 17:54:21 +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
3cb574102a Add idiom brackets 2020-01-26 17:24:25 +00:00