Commit Graph

524 Commits

Author SHA1 Message Date
Edwin Brady
e08ff47a93
Merge branch 'master' into code-golf 2019-09-13 13:17:39 +01:00
Edwin Brady
9c01bbc886
Merge pull request #97 from lodi/coreutils
Fixed #!/usr/bin/env shebang for Chez backend
2019-09-13 13:14:39 +01:00
Edwin Brady
4159d43432
Merge pull request #75 from abailly/configurable-ide-mode-socket
Configurable ide-mode-socket REPL
2019-09-13 13:13:02 +01:00
Edwin Brady
421b15aa24 Detect cycles in imports 2019-09-07 14:54:29 +01:00
Alex Gryzlov
e669140f9a code golfing 2019-09-05 03:21:43 +03:00
Edwin Brady
412930522e Put idris version number in package install path
Since they'll be incompatible between different Idris2 versions, this
helps protect against importing the wrong thing by mistake. Also, it
means the canonical place for the version number is now the top level
Makefile.

You'll need to delete src/YafflePaths.idr before rebuilding, since it's
now generated slightly differently.
2019-09-04 16:20:26 +01:00
Edwin Brady
65db4fbf96 Put built ttcs in build/ttc, rather than build
This is so that we can put other build artefacts (e.g. executables) in
properly organised subdirectories of build, e.g. build/bin/chez,
build/bin/js, etc.
2019-09-04 12:41:16 +01:00
Edwin Brady
68b0d64879 Add parameterised pointer type
For at least a bit of safety in foreign APIs. AnyPtr has the old Ptr
behaviour.
2019-09-04 10:25:45 +01:00
Edwin Brady
de0a097a40 First attempt at a C FFI via Racket
This aims to be consistent with the notation for the way the Chez->C FFI
loads libraries.
2019-09-03 17:02:23 +01:00
Edwin Brady
25bbaf7d74 Add dynamic library extension
In the Chez back end, if the library spec is a name and a version
number, build an appropriate guess for the library file name based on
the system extension.
2019-09-03 14:37:16 +01:00
Edwin Brady
bb246a072a Experimenting with a new FFI
Functions can be declared as %foreign with a list of calling
conventions, which a backend will work through until it finds one it can
understand. Currently implemented only in Chez backend. If this works
out, I'll implement it for Racket too, and remove the old primitive
functions.

There's a bit more boiler plate here than before, but it has the benefit
of being more extensible and portable between different back ends.

Some examples, pending proper documentation:

%foreign "C:puts,libc" "scheme:display"
putline : String -> PrimIO ()

%foreign "C:exp, libm.so.6, math.h"
fexp : Double -> Double

%foreign "C:initscr, ncurses_glue.so, ncurses.h"
prim_initscr : PrimIO ()
2019-09-02 17:10:48 +01:00
lodi
ba7e0e01d3 Fixed #!/usr/bin/env shebang for Chez backend
On NixOS, idris2 can't find scheme in the usual locations, so it
defaults to generating the following shebang:

  #!/usr/bin/env scheme --script

The `env` program interprets `scheme --script` as one monolithic
command, instead of as a command and one argument.

  /usr/bin/env: ‘scheme --script’: No such file or directory
  /usr/bin/env: use -[v]S to pass options in shebang lines

The -S flag forces `env` to split on whitespace in the intuitive
manner.
2019-08-30 14:48:54 -04:00
Arnaud Bailly
3dcd48e08b
Merge branch 'master' into configurable-ide-mode-socket 2019-08-29 16:24:17 +02:00
Arnaud Bailly
643fc9c4c7
provide Version command in ide-mode 2019-08-29 14:37:38 +02:00
Arnaud Bailly
558776c4c4
remove version number from banner at REPL startup
otherwise all tests will need to change every time version changes...
2019-08-29 14:37:04 +02:00
Arnaud Bailly
4646bb0d1c
expose current Idris2 version as a proper type 2019-08-29 14:37:04 +02:00
Edwin Brady
ea75fd21a1 Merge branch 'master' of github.com:edwinb/Idris2 2019-08-29 11:10:44 +01:00
Edwin Brady
2005b82f6d
Merge pull request #81 from clayrat/file-leak
Fix file handle leaks
2019-08-29 11:04:35 +01:00
Edwin Brady
93de7d69b4
Merge pull request #80 from timsueberkrueb/repl-allow-empty-lines
Ignore empty lines in REPL
2019-08-29 11:01:54 +01:00
Edwin Brady
dba128ae69
Merge pull request #73 from chrrasmussen/add-output-flag
Add output file flag (-o) to CLI
2019-08-29 10:57:22 +01:00
Edwin Brady
718f5963ce
Merge pull request #70 from jfdm/expand-ipkg-contents
Align the IPKG format more with the previous Idris implementation.
2019-08-29 10:51:41 +01:00
Edwin Brady
8975eeafb7 Make a start on reflection 2019-08-27 15:49:21 +01:00
Arnaud Bailly
3a33dc3d7d
add specialised option to listen on different host/port 2019-08-26 17:42:15 +02:00
Arnaud Bailly
43d9c575e1
Merge branch 'master' of https://github.com/edwinb/Idris2 into configurable-ide-mode-socket 2019-08-26 08:20:37 +02:00
Edwin Brady
9fb820f659 Re-evaluate type on delayed alternative elab
Fixes #92, because it wasn't re-evaluating the type and establishing
that the thing it was looking for must be a Fin for fromInteger so
resorting to the default integer literal instead.
2019-08-22 12:36:36 +02:00
Arnaud Bailly
64b0c10356
Merge branch 'master' of https://github.com/edwinb/Idris2 into configurable-ide-mode-socket 2019-08-17 12:56:38 +02:00
Edwin Brady
c01986a62e Preserve order of arguments in unification
Sometimes we swap the arguments, to reduce code duplication, but we need
to remember we've done that since (1 x : a) -> b is valid for an
argument of type (x : a) -> b, but not vice versa (that is, we have a
teensy bit of subtying to deal with, for convenience...).

This fix seems a bit ugly, but we do at least now propagate the
information. Fixes #82.
2019-08-16 11:32:16 +01:00
Andre Kuhlenschmidt
20a2cc0f31 Add a case in the repl for empty command
Changes to be committed:
	modified:   src/Idris/REPL.idr
2019-08-14 16:41:58 -04:00
Alex Gryzlov
e7aafcc14a fix file handle leaks 2019-08-13 23:53:07 +03:00
Tim Süberkrüb
ae841108ef Ignore empty lines in REPL
This ignores empty lines in the REPL and doesn't show a parse error on
CTRL+D/EOF anymore.
Add NOP variant to REPLCmd to represent an empty command.
Split command in eoi or nonEmptyCommand. nonEmptyCommand is still
guaranteed to consume input. command may be eoi in which case it does
not consume input.
Print a newline after receiving EOF on the console. Since this is only
relevant in the REPL (quiet or not) this uses putStrLn rather than
iputStrLn.
2019-08-11 20:38:12 +02:00
Edwin Brady
a87a3c14c2 Delay should always delay, not just under Inf
I don't know why I originally made it 'Inf' only in the evaluator... but
we certainly want 'Lazy' delays to block too, especially if they're
guarding non-terminating computations.
2019-08-06 14:54:27 +01:00
Edwin Brady
9bb91b5656 Allow deferring definitions to other modules
This is supported by Idris 1 and is handy for breaking cycles in
modules. To achieve this, we just need to make sure that complete
definitions aren't overwritten with empty definitions on loading.
2019-08-06 13:33:30 +01:00
Edwin Brady
010ec7a757 Add :m/:metavars command to REPL 2019-08-06 11:50:11 +01:00
Arnaud Bailly
c40eabc7e5
provide a socket-based client REPL 2019-08-06 10:46:02 +02:00
Christian Rasmussen
7c858ec5ab Add output file flag (-o) to CLI 2019-08-03 22:18:49 +02:00
Arnaud Bailly
74a27f3861
make Client actually work 2019-08-03 11:36:54 +02:00
Arnaud Bailly
b682accc0b
Merge branch 'master' of https://github.com/edwinb/Idris2 2019-08-02 07:08:34 +02:00
Jan de Muijnck-Hughes
9839664d32 Align the IPKG format more with the previous Idris implementation. 2019-08-01 12:47:08 +01:00
Edwin Brady
e95c5f7571 Remove unnecessary check from let elaboration
Checking the let expression in full can break sharing when unifying the
types, and it's unnecessary because we've already checked the type of
the scope unifies with the expected type.
Fixes #63
2019-07-31 10:10:47 +01:00
Edwin Brady
f39b736110
Merge pull request #66 from abailly/no-prelude
check noprelude option when starting up without loading a file
2019-07-30 16:47:08 +01:00
Arnaud Bailly
ff7180e6b5
check noprelude option when starting up without loading a file #65 2019-07-30 13:56:27 +02:00
Edwin Brady
47ad8ee7f5 Propagate implicits to with clauses
Fixes #57. Also move much of the 'with' machinery to its own source
file.
2019-07-30 12:32:33 +01:00
Edwin Brady
7e1c24a559 Elaborate default methods at given multiplicity 2019-07-29 14:53:01 +01:00
Arnaud Bailly
48ad84af0f
Merge branch 'master' of https://github.com/edwinb/Idris2 2019-07-29 14:13:58 +02:00
Edwin Brady
e6cf936331 Make sure hole names are unique
Fixes #6
2019-07-28 21:04:55 +01:00
Edwin Brady
aaaf3a873b Check implicit searches are complete
Fixes #55
2019-07-28 18:27:43 +01:00
Edwin Brady
56a09b033f
Merge pull request #59 from clayrat/empty-modules
Allow empty modules
2019-07-28 15:25:46 +01:00
Edwin Brady
db18f08e49
Merge pull request #54 from ether42/unrecognised
Make it a little easier to debug IDE mode
2019-07-28 15:25:20 +01:00
Edwin Brady
b3c53a3b54
Merge pull request #53 from ether42/master
Only display IDE port when listening
2019-07-28 15:23:44 +01:00
Edwin Brady
f1a4e0c09d Change elaboration of lets
Elaborate the scope of a let without the computational behaviour,
meaning that `let x = v in e` is equivalent to `(\x => e) v`. This makes
things more consistent (in that let bindings already don't propagate
inside case or with blocks) at the cost of not being able to rely on the
computational behaviour in types. More importantly, it removes a
significant potential source of slowness.

Fixes #58

If you need the computational behaviour, you can use a local function
definition instead.
2019-07-28 13:43:01 +01:00
Edwin Brady
d5409ac2d0 Add 'libs' directory to paths
This is for finding support libraries for code generators, e.g. the
shared objects that chez will load for glue code for foreign libraries.
It'll be used more shortly...
2019-07-28 11:48:00 +01:00
Alex Gryzlov
fb832cb49c allow empty modules 2019-07-28 12:43:25 +03:00
Edwin Brady
0bb9a13d37 Update method names when checking default methods
Fixes #42. If we don't do this, the name is treated in the saem way as
an unbound implicit, which is not what we want, so update with the
method applied to the parameters.
2019-07-27 17:01:02 +01:00
Arnaud Bailly
5a555641a0
Merge branch 'master' of https://github.com/edwinb/Idris2 2019-07-27 17:03:26 +02:00
Kevin Boulain
86b1e43274 Make it a little easier to debug IDE mode 2019-07-27 15:58:22 +02:00
Edwin Brady
19a079511d
Merge pull request #51 from clayrat/record-fix
fix implicit/brace block ambiguity in records
2019-07-27 13:58:13 +01:00
Kevin Boulain
45329df3a5 Only display IDE port when listening 2019-07-27 14:47:37 +02:00
Edwin Brady
81fefed3f3 No need to decorate implicit record fields 2019-07-27 13:19:49 +01:00
Edwin Brady
5f385527c6 Remove unnecessary source file 2019-07-27 12:05:32 +01:00
Alex Gryzlov
20c57eafc1 fix implicit/brace block ambiguity in records 2019-07-27 02:16:35 +03:00
Edwin Brady
f86ba8cc9b Use any local at multiplicity 0
When searching for an auto implicit, if we're at multiplicity 0 we can
use any local (e.g. when searching in a type).

Fixes #49
2019-07-26 23:10:41 +01:00
Edwin Brady
fa76f2a78b Bind auto implicit arg names in LHS
We were only doing implicits, so add auto implicits too. It's slightly
tricky, because we might also have implicits given of the form @{x}
which stands for the next auto implicit.

Fixes #50
2019-07-26 16:58:02 +01:00
Edwin Brady
8e9655dd9b Unbound implicits are invertible in terms
Just like all other pi-bound things, if m is an unbound implicit and we
have m ?x = m y as a unification problem, we can conclude ?x = y because
it has to be true for all ms.

This was implemented in Blodwen but I hadn't got around to it yet for
Idris2... fortunately it's a bit easier in Idris2!

Fixes #44
2019-07-26 12:27:54 +01:00
Edwin Brady
4f4d4ccbe9 Store invertibility in definition, not hole
This will be useful shortly, and in general because it'll give us more
flexibility in unification to be able to spot things which are
guaranteed invertible like constructors.
2019-07-26 00:00:03 +01:00
Edwin Brady
36b5081a4e
Merge pull request #16 from clayrat/clean-ipkg
Add --clean option for ipkg
2019-07-23 15:14:02 +01:00
Kamil Shakirov
71e34596cb Add missing double quotes 2019-07-23 14:54:58 +06:00
Edwin Brady
86eb475413 Check for name clashes in impl constraints
We were only checking parameters, meaning that there were potential
clashes leading to confusing behaviour, and meaning that it was somehow
relevant what the names were in the interface!
2019-07-22 23:16:51 +01:00
Arnaud Bailly
db8079bae6
Merge branch 'master' of https://github.com/edwinb/Idris2 2019-07-22 17:22:39 +02:00
Edwin Brady
7e67ba4f35 Allow marking interface methods multiplicities
Now by marking a method as multiplicity 0, we can explicitly say that
it's compile time only, so we can use it to compute types based on other
erased things - see tests/idris2/interface008 for a small example.

This fixes #8 - at least in that it allows the interface to be expressed
properly now, although the multiplicity annotations mean that
unfortunately it can't be compatible with Idris 1.
2019-07-22 16:21:33 +01:00
Edwin Brady
91262b4800 Fix possible loop in auto implicit search
A local variable can't be applied to itself when searching (otherwise,
for example, we could end up trying something like id id id id id id etc
forever). So remove it from the environment before searching for its
arguments.

This and the previous patch fix #24. (Or, at least, the minimised cases
reported as part of it!)
2019-07-22 11:21:34 +01:00
Edwin Brady
0e4c610f56 Fix for interfaces with parents
Don't use the interface itself when checking parent implementations
exist, otherwise we'll end up in a cycle (because the parent
implementation will sort of exist as a result!)
2019-07-22 11:21:34 +01:00
Edwin Brady
d9719f53a5
Merge pull request #38 from chrrasmussen/docs-for-exp-log
Document base for exp and log functions
2019-07-21 13:43:33 +01:00
Edwin Brady
45b6d5165c
Merge pull request #33 from simonchatts/master
Use ahead-of-time compilation with Chez
2019-07-21 13:43:04 +01:00
Arnaud Bailly
dc9ab95adb
Merge branch 'master' of https://github.com/edwinb/Idris2 2019-07-21 07:48:49 +02:00
Arnaud Bailly
72f579aaa9
[wip] introduce IDE-mode Client
* immediate goal is to be able to write tests against the IDE-mode
  server
* next goal would be to have a REPL talking to a server
2019-07-21 07:14:46 +02:00
Christian Rasmussen
7310776603 Document base for exp and log functions 2019-07-21 02:14:48 +02:00
Christian Rasmussen
cafae8f11d Fix primitive function for acos 2019-07-21 01:47:47 +02:00
Edwin Brady
6d90b72fe9 Check under data constructor for holes
We can't begin a search until we know what we're searching for! For some
reason I forgot to add this case, and without it the search space can
explode, or we might find an answer too soon and commit to the wrong
thing!

Fixes #36
2019-07-20 21:09:33 +01:00
Edwin Brady
cae9162fcf Check under 'as' patterns for case arg usage 2019-07-20 18:57:03 +01:00
Edwin Brady
6dd18d798a Allow annotating functions with multiplicity
This means we can write truly type level only functions, by annotating
them with a 0 before the type declaration.
2019-07-20 18:04:18 +01:00
Edwin Brady
607e280895 Place implicits through to method bodies
This means that even if the relevant parameters aren't used by a method
body, the method can still see what the implicits are (though they will
be 0 multiplicity).

This is relevant to #8, but doesn't really fix it because we still need
a way of saying that methods are 0 multiplicity.
2019-07-20 16:25:40 +01:00
Edwin Brady
e902340346 Change elaboration of parent constraints
We need to turn pairs into separate constraints, which is a bit of a
hack but the constraints need to be separate in order to build the
chasing functions which find the parent constraints correctly.

Possibly there is a neater way, which is to teach the search algorithm
to look in the hints for pairs, but that's a lot more complicated (and
probably unnecessarily so).

Fixes #25
2019-07-19 11:51:40 +01:00
Arnaud Bailly
4f21234c9e
basic test for --ide-mode
how to take care of input termination properly? currently we add the
message 'Alas the file is done' in the expected outcome but that's
ugly
2019-07-19 12:34:15 +02:00
Simon Chatterjee
3bee97c0b9 Use ahead-of-time compilation with Chez
This is a bit rough, but does yield an executable with a ~40% speedup in
startup latency on one test. The resulting executable is a .so file with a #!
invocation of the local chez scheme executable to run it, so the binary isn't
portable (even to a machine with the same architecture/OS) unless there's an
identical chez installation on both machines.

As with the .ss source, the .so is currently leaked in the temporary directory.
2019-07-19 10:27:15 +01:00
Edwin Brady
677ddea9c5 Only check determining arguments at the top level
They're just about deciding whether it's okay to start an auto implicit
search, not whether it's okay to continue search, which is part of the
problem in #25.
2019-07-18 20:32:03 +01:00
Edwin Brady
b601abee9d
Merge pull request #22 from PeterHajdu/openbsd
Use fgetc instead of getc
2019-07-18 20:23:44 +01:00
Edwin Brady
d00a482667 Fix C calls from Chez
This hasn't been tested much (and indeed isn't in the test suite because
I haven't found the way to load shared objects nicely portably yet!) so
I hadn't noticed, but primitive types are translated to names before
compilation to support matching on types, so we need to account for
this.

Also, CG directives need to be processed after loading from ttc
2019-07-18 11:25:41 +01:00
Peter Hajdu
1265856698 Use fgetc instead of getc
On openbsd getc is a macro that expects its parameter to be FILE*
whereas the generated code provides void*.
2019-07-17 19:10:07 +02:00
Arnaud Bailly
3520f7d6fe
allow running IDE mode on different network interfaces 2019-07-16 16:34:57 +02:00
Alex Gryzlov
8e37fe697a blodwen -> idris2 2019-07-15 14:37:05 +03:00
Alex Gryzlov
4d3b42747c add --clean option for ipkg 2019-07-15 14:36:54 +03:00
Edwin Brady
0d5dc8cc26 Check delay is allowed before delaying
We can't nest delayed elaborators (this is an efficiency constraint, to
prevent excessive searching for ambiguous names) to run elaborator
immediately if delays aren't allowed in delayElab
2019-07-14 11:23:58 +01:00
Edwin Brady
39ee4ad9c8 Numeric range syntax 2019-07-12 09:32:36 +02:00
Edwin Brady
4860d2b751 Add Range interface to prelude
This is part of what we used to have in Enum but I think it's better to
separate the two. Added implementations for Nat, and anything in
Integral/Ord/Neg, so that we get range syntax (at least when its
implemeted) for the most useful cases.
2019-07-11 23:38:25 +02:00
Edwin Brady
fd4f90e331 Add some Control.Monad things
This required a small change to auto implicit search (and I'm still not
sure about this). Now search arguments right to left, because solving
later arguments may resolve earlier arguments by unification and this
can happen in particular when chasing parent interfaces (which may have
fewer parameters).
2019-07-10 20:18:40 +02:00
Edwin Brady
4fffea482b Tweak to auto search errors
Take the earliest failure message, since they'll typically be more
precise (later search groups being for chasing parent interfaces and
defaults). This is mostly as a heuristic to help show whether one part
of a pair failed in implicit search.
2019-07-10 19:12:13 +02:00
Edwin Brady
9f6a3fd2b8 Fix in scheme backend and test script
At least on Linux, \r needs to be in singles quotes as an argument to tr
or it removes all the 'r' instead! Hopefully it also works this way on
Windows...
2019-07-10 17:23:45 +02:00
Edwin Brady
a422294f36 Pass auto implicits through interfaces
This allows 'traverse' to work now (it was treating them as normal
implicits, so building the wrong form of application)
2019-07-10 17:23:33 +02:00
Edwin Brady
e5a71e758a Add records in their own namespace
These are 'nested' namespaces which are a bit special in that even
private names are visible from the enclosing namespace. This gets the
behaviour for record visibility from Idris 1.
2019-07-10 16:55:28 +02:00
Edwin Brady
1119c089bf Don't pass let bound things to with function
These are let bound things in the local environment, which could happen
if the with clause is in a where block.
2019-07-10 16:55:28 +02:00
Niklas Larsson
28438650d0 windows support 2019-07-10 01:51:41 +02:00
Edwin Brady
2bb496f74b Chapter 11 examples now working 2019-07-08 23:46:20 +02:00
Edwin Brady
11560a5c82 Make 'with' work in where blocks
Need to set up nested names appropriately for the with function so that
the environment gets passed through correctly, and use abstractEnvType
to get the type of the with function rather than simply binding the
environment as is.
2019-07-08 23:05:04 +02:00
Edwin Brady
13520165e9 Only add a force on function types
If it's not a function type, we're done, so no need to force.
2019-07-08 21:55:45 +02:00
Edwin Brady
9740438319 Small improvement in error messages
Show MNs as "implicit" names rather than showing the internal name in
full
2019-07-08 14:11:54 +02:00
Edwin Brady
11199acab6 Improve 'with' implementation
Now supports with applications on the RHS when auto implicits are
involved. Auto implicit bound names in patterns now become searches on
the rhs in a with-application (I should write this construct up properly
in a paper some time!)
2019-07-08 12:55:55 +02:00
Edwin Brady
51c406ff7d Deal with non-existent files more gracefully
So now you can start idris2 with a non-existent file and use :e to start
editing it
2019-07-07 13:10:14 +01:00
Edwin Brady
ccc53813ca Initial attempt at RHS with application
Still some details to finish, plus testing, plus adding View modules to
the base libraries, but the basic idea works.
2019-07-07 00:07:59 +01:00
Edwin Brady
62382dcd96 Change fields in ElabInfo
We don't use level, so remove it. Added a field bindingVars which
records whether implicit names should be bound if unsolved. This needs
to be separate from the elaboration mode because we might encounter new
holes inside dot patterns which are matched elsewhere.
2019-07-06 13:57:20 +01:00
Edwin Brady
4ab543b83d A bit more library support, for Chapter 9
Also a tweak to errors when compiling to scheme, so that it properly
reports an error then quits if it's supposed to crash.
2019-07-05 17:24:15 +01:00
Edwin Brady
bdf6c03bf1 Use primitive constants as a last resort
This is for the situation where there's still an ambiguous overloading,
we drop to using the built in primitive as a default.
2019-07-05 16:40:08 +01:00
Edwin Brady
27672444e4 Add flag for whether a hole is an unbound implicit
We use this to decide whether a determining argument is satisfied or not
for unbound implicits. We can tell from the name, which would be a PV,
but this way relies on fewer assumptions.
2019-07-05 14:58:48 +01:00
Edwin Brady
86f402c948 Add a 'match' mode to unification 2019-07-05 13:59:57 +01:00
Edwin Brady
7c34fa1db4 Change equality elaboration
Elaborate via either === (homogeneous equality) or ~=~ (heterogeneous
equality) both of which are synonyms for Equal. This is to get the Idris
1 behaviour that equality is homogeneous by default to reduce the need
for type annotations, but heterogeneous if that doesn't work.
2019-07-05 11:26:45 +01:00
Edwin Brady
40d9235b3f Allow ambiguity when chasing parent interfaces
There's a bit of a trade off here. It would be better to report the
ambiguity but this would lead to a need for (I think) excessive
precision in types which would impact usability. It will always take the
leftmost interface.

Chapter 7 tests added.
2019-07-05 10:29:41 +01:00
Edwin Brady
aa58114671 Add 'last chance' unification and tweak guesses
Idris 1 will fill in the last metavariables by matching rather than
unification, as a convenience. I still think this is okay, even if it's
a bit hacky, because it's a huge convenience and doesn't affect other
unification problems.

Also abstract over lets in guesses, like in delayed elaborators, to
avoid any difficulties when linearity checking and to make sure that let
bound things don't get reevaluated.

This is enough to get the Chapter 6 TypeDD tests working
2019-07-05 00:09:00 +01:00
Edwin Brady
c260f6c90e Improve dot patterns
Allow matching rather than unification, as long as it doesn't solve any
metavariables on the way. I noticed a potential unification bug on the
way, forgetting to update whether holes are solved when unifying
argument lists.
2019-07-04 23:16:08 +01:00
Edwin Brady
12b6604e4b Need to abstract over lets in 'argVar'
Otherwise instantiating won't work, and in any case we want to make sure
that let bound values don't need recalculating
2019-07-04 12:16:00 +01:00
Edwin Brady
4f4be770ad Don't look inside guesses for metavariables
This will happen if there's an error earlier in the file, and only leads
to a cryptic error message
2019-07-04 10:54:01 +01:00
Edwin Brady
6f5d3f5fef Unelaborate hole applications properly
This was left over from Blodwen (where it was also wrong :)) but the way
we apply metavariables now means we don't need to do anything fancy when
unelaborating them for pretty printing.
2019-07-03 15:31:46 +01:00
Edwin Brady
89c8314a0f Desugar pattern matching lambdas 2019-07-03 15:11:57 +01:00
Edwin Brady
0f56c239c2 Parse pattern matching lambda
This is now enough for Chapter 5 tests to work
2019-07-03 13:04:25 +01:00
Edwin Brady
4abe760cc9 Update type on delayed rewrite
Like in delayed ambiguity resolution, we need to reevaluate the target
type because it might have changed - and that's why we delayed in the
first place!
2019-07-03 11:02:53 +01:00
Edwin Brady
e526badfe2 Delay case elaboration
This helps a few things because it delays elaboration of the block until
as much as possible is known about its type.

Also added a few libraries.
2019-07-02 16:53:41 +01:00
Edwin Brady
2efaaa6b79 Substitute in 'simple' metavariable solutions
Where "simple" means the solution is just a local variable or smaller
metavariable application. This is a big win when environments get big,
and I suspect there might be more where this came from if we always
shrink the environments of metavariable solutions as far as possible. It
really saves a lot of work in "quote" in particular.
2019-07-01 16:50:11 +01:00
Edwin Brady
c6d7c6ca6c Some performance improvements
Surprisingly == on Nat in the Idris prelude is linear! So shortcut that
by converting to an Integer first. Also a couple of small things in the
evaluator that have a small but noticeable effect when environments are
big.
2019-07-01 12:43:02 +01:00
Edwin Brady
b577532f57 Save time lexing if we're only reading headers 2019-07-01 00:21:35 +01:00
Edwin Brady
00514887c4 More base libraries
This has shown up a problem with 'case' which is hard to fix - since it
works by generating a function with the appropriate type, it's hard to
ensure that let bindings computational behaviour is propagated while
maintaining appropriate dependencies between arguments and keeping the
let so that it only evaluates once. So, I've disabled the computational
behaviour of 'let' inside case blocks. I hope this isn't a big
inconvenience (there are workarounds if it's ever needed, anyway).
2019-06-30 23:54:50 +01:00
Edwin Brady
f2dff5cae4 Normalise holes in error messages
The solved holes may not outlive the error, so normalise before throwing
so that they can be displayed properly.
2019-06-30 17:23:19 +01:00
Edwin Brady
7998b27d66 Use exact->inexact when casting to doubles
Otherwise things may look like rationals, which is probably not what we
want in general
2019-06-30 16:46:09 +01:00
Edwin Brady
f37da6c5b7 Start adding tests for TypeDD book
Also detailing any changes needed to the code. Added primitives for
Doubles, and repl/replWith to get Chapter 2 code to work.
2019-06-30 15:50:58 +01:00
Edwin Brady
eddb23d108 Need to save postponed names in ttc too
Flag these when searching names for references
2019-06-30 12:49:11 +01:00
Edwin Brady
ae777b8dcb Add parameters blocks 2019-06-29 23:55:17 +01:00
Edwin Brady
2f4cdf857d Make typecase on -> work 2019-06-29 22:43:06 +01:00
Edwin Brady
f9ea1ff329 Updating typecase, add tests 2019-06-29 21:32:19 +01:00
Edwin Brady
7aa8a71f8f Fix loading of hints, and add test
Need to add by full name, due to ordering of loading (the name it's
attached to may not be resolved yet!). This doesn't seem to cause any
performance problems but we can revisit if it does.
2019-06-29 20:51:48 +01:00
Edwin Brady
a65d1efa38 Throw error if case type is not inferred
This is probably quite rare to want, but we could consider putting this
under a delayOnFailure
2019-06-29 19:39:11 +01:00
Edwin Brady
99dac56e1e Make sure matches are not too specific
i.e. if an argument has a polymorphic type, we shouldn't allow a
concrete type in its place
2019-06-29 19:28:04 +01:00
Edwin Brady
cda87a9c16 Fix coverage checker issue
Don't use the type of a scrutinee to restrict possible patterns, because
it might have been refined by a Rig0 argument that has a missing case.
Instead, generate all the possible cases and check that the generated
ones are impossible (there's no obvious change in performance)
2019-06-29 16:41:26 +01:00
Edwin Brady
39836f3cd0 Fix instantiation in pattern unification
There was an optimisation that wasn't valid, and it turns out it doesn't
have any useful effect anyway.
2019-06-28 19:41:25 +01:00
Edwin Brady
9b44839c57 Add test for eta 2019-06-28 12:43:55 +01:00
Edwin Brady
e9a3167e2f Even more tests
Small change needed to fix one - assume given implicits which are of the
form x@_ arise from types. It's a bit of a hack but I don't think
there's any need for anything more complicated.
2019-06-27 20:19:00 +01:00
Edwin Brady
b0cad15c65 Refine dot pattern rules
Only valid if unifying the pattern at the end doesn't solve any
metavariables. Also when elaborating applications of fromInteger etc to
constants on the LHS we need to be in expression mode, then reduce the
result later.
2019-06-27 19:16:33 +01:00
Edwin Brady
211de419bb Fix environments for nested names
This was a slight difference from Blodwen that wasn't accounted for -
there might be lets in the nested environment, so when building the
expanded application type, make sure we go under them
2019-06-27 15:26:18 +01:00
Edwin Brady
d053a18977 Set fresh name counter on loading Main ttc
Make sure this is the counter from the right namespace, or we might get
name clashes at the REPL
2019-06-27 14:47:47 +01:00
Edwin Brady
ce78abaaef Build and save references for metavars too
This wasn't necessary before, since we always inlined, but since we can
now postpone things longer and don't always inline until much later, we
need to know what names everything refers to earlier.
2019-06-27 09:01:59 +01:00
Edwin Brady
3eda2494bf Add error message tests 2019-06-25 21:46:28 +01:00
Edwin Brady
7b504e7a9e More Chez tests 2019-06-25 21:27:46 +01:00
Edwin Brady
69199639cf Fix Nat hack
And add chez scheme section to tests, with one initial test
2019-06-25 14:05:54 +01:00
Edwin Brady
bf64f843aa A bit more totality checking polish
Need to check for 'assert_total' in getRefs, and get Inf and Lazy the
right way around!
2019-06-25 12:57:49 +01:00
Edwin Brady
0b4f4ec46d Fix naming issue in totality checker
Also added a new test
2019-06-25 10:26:14 +01:00
Edwin Brady
5caa277cbe Fix some totality issues, add tests
These are related to the change in naming and metavariables, mostly
2019-06-25 00:42:52 +01:00
Edwin Brady
e68b9134e7 Calculate parameter positions in types 2019-06-24 19:31:25 +01:00
Edwin Brady
32583d608d More interface tests
and a small fix for the generation of method types which was okay for
Blodwen, but not here
2019-06-24 18:04:43 +01:00
Edwin Brady
e9514f3c22 Add first interface tests 2019-06-24 17:36:55 +01:00
Edwin Brady
e6292acdf0 Finish adding interactive tests from Blodwen
This involved implementing the 'TryWithImplicits' hack for allowing
unbound implicits in types with case blocks
2019-06-24 16:23:32 +01:00
Edwin Brady
1e2fcb8ccd Fix small error is as patterns
Also added new interactive test
2019-06-24 15:30:36 +01:00
Edwin Brady
7a47c9ae0c Add a couple of interactive tests 2019-06-24 15:16:49 +01:00
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