Commit Graph

297 Commits

Author SHA1 Message Date
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
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
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
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
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
Christian Rasmussen
7c858ec5ab Add output file flag (-o) to CLI 2019-08-03 22:18:49 +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
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
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
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