Commit Graph

1188 Commits

Author SHA1 Message Date
Edwin Brady
048bce23a6 Make inlining faster with One Weird Trick
Or, more accurately, by not doing a thing that's a waste of time. After
evaluating a local, if the result isn't applied to a stack, there's no
more reduction to do, so stop there.

Still go to the explicit named representation afterwards, since that's
an easier API for a code generator, and by then the names are guaranteed
unique.
2020-04-15 21:46:28 +01:00
Guillaume Allais
8eabc27dac [ refactor ] boolean expression 2020-04-15 20:55:18 +01:00
Ohad Kammar
95da5a8b74 Refactor to allow supporting implicit and rit annotations on records
(without adding syntax for them)

Somewhat of a surgical change, changing the AST and elaboration to
support it

Seems to pass all tests (including Frex)

Changes in `Idris/Desugar.idr` seem to be a bit challenging for the
type-checker in do-blocks, so I added type annotations.
Hopefully we could remove them in `idris2sh`.
2020-04-15 18:30:26 +01:00
Guillaume Allais
eabb23f8ce [ refactor ] remove redundant check isLet
The `isLet` check is essentially the disjunction of the `Maybe Bool`
and the function looking up the value to check whether it is a `Let`.
But:

* `getBinder` does the same lookup & then dispatches on Let
* the non-let cases in both branches of the if-then-else are equal

So we can actually get rid of that `isLet` and it should compute the
same result. We still use the `Maybe Bool` to potentially avoid running
`getBinder` if we already know the local value is not a let.
2020-04-15 14:15:02 +01:00
Guillaume Allais
9152caded1 [ cleanup ] use reverseOnto
Instead of essentially interleaving the proof that `reverseOnto`
and ̀`reverse _ ++ _` are equivalent, we embrace `reverseOnto` and
perform a single rewrite at the end.
2020-04-15 13:54:02 +01:00
Guillaume Allais
3ae4267de9 [ refactor ] following discussion with @ziman
Cf. 654ab0cbd0 (r38389015)
2020-04-15 13:53:51 +01:00
Guillaume Allais
b60fdf2c0d [ doc ] for the case tree constructors 2020-04-15 13:53:43 +01:00
Edwin Brady
d5bfb8f136 Use explicit named representation for compiling
Apologies to anyone who's working on a back end independently!

You can still use CExp for now, but I'm shortly going to try using
NamedCExp in inlining, to save the fairly large cost of maintaining the
de Bruijn indices when going under binders.

Names are kept unique in the translation, so you can assume you don't
need to worry about them.
2020-04-15 11:14:02 +01:00
Arnaud Bailly
5544919c31 use quotient on scheme backends
We compile divisions of Integers to quotient instead of '/' and add
some tests for numbers
2020-04-15 10:52:35 +02:00
Ohad Kammar
0254ff109c Merge branch 'master' of github.com:edwinb/Idris2 into fully-abstract-records 2020-04-15 08:46:12 +01:00
Matus Tejiscak
41ef3fdd2a Don't use exact-floor in cast-string-int. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
c3b6b130fd Also fix up cast-string-int. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
7a3ebd9a2f Use exact-floor. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
18962eeacf Fix casting in integral division. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
cf177f95a4 Fix conversion from Double to integral types. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
b5689e5b25 Disable tests relying on cast-string-int. 2020-04-14 22:44:18 +02:00
Matus Tejiscak
1112f01dc6 Add reg016 to tests. 2020-04-14 22:12:36 +02:00
Matus Tejiscak
4827d0447b Add division tests. 2020-04-14 22:01:31 +02:00
Matus Tejiscak
c7fe4f1a63 Update the expectation file. 2020-04-14 21:36:14 +02:00
Matus Tejiscak
b20ae8d36b Add a test. 2020-04-14 21:30:04 +02:00
Arnaud Bailly
2b0cc2a592 provide building blocks for binary network I/O 2020-04-14 21:15:32 +02:00
Edwin Brady
843619790e Another small improvement in code generation
Use a variant of MkVar which has the name in the type and therefore
means it can be erased to a newtype, so just an Integer. Then use
'insertNames' rather than repeatedly thinning.
2020-04-14 20:03:35 +01:00
Guillaume Allais
f10edd51f5 [ fix #279 ] comment delimiters with more than one dash 2020-04-14 14:13:38 +01:00
Kamil Shakirov
d258584a9f Ditto 2020-04-14 18:28:06 +06:00
Edwin Brady
849a1da846 Erasure correctness
A bit of reorganisation to ensure that the context membership proofs are
erased. It's only a small overhead in general to keep the proofs, but
there are places where it's really noticeable, particularly when
compiling large programs.
2020-04-14 13:13:59 +01:00
Jeetu
9a9101ab0f Merge https://github.com/edwinb/Idris2 into sync
Updating latest code from edwinb repo.
2020-04-13 17:53:28 +05:30
Jeetu
00fc9a603d Refactored the docs directory for latest sphinx_rtd_theme.
Source and build directory are seperate.
References and footnotes are named.
Other than that, tried to do no changes in the docs.
Fixed multi label in proofs-index.
Fixed most of the warnings in make html.
HTML and PDF are building.
2020-04-13 17:45:52 +05:30
Jeetu
5175743e78 Removed docs directory for adding new docs. 2020-04-13 17:41:59 +05:30
Jeetu
db25e81d48 Mostly references naming. Still footnotes are not coming on the same line as its number. 2020-04-13 16:40:23 +05:30
Edwin Brady
806e8d2569 Faster inlining phase of compiler
It's still too slow, but better than it was. Instead of all the
weakening, invent a new name when evaluating under a lambda and
substitute later.
Possibly we can improve this later by substituting in batches, like the
main evaluator does.
2020-04-12 22:37:11 +01:00
Edwin Brady
0ed9f6cee6 Occasional performance boost
Check for conversion without reducing names, before unifying arguments.
This is quick to check, and can save a lot of evaluation.
2020-04-12 18:01:45 +01:00
Edwin Brady
841c3f27a5 Change order of argument search in auto implicits
For consistency with interactive expression search
2020-04-10 15:39:45 +01:00
Edwin Brady
69a7640a6e Allow flagging types as externally defined
e.g. in a C file. This means we don't accidentally treat things as
empty, since previously we just defined these as empty types, but that
broke coverage checking. Fixes #240
2020-04-10 11:45:52 +01:00
Jeetu
a24511eae2 Spelling mistake corrected. 2020-04-10 16:14:54 +05:30
Jeetu
a9ac084b8c Added instruction for virtual environment for python. 2020-04-10 13:34:03 +05:30
Edwin Brady
0daece1e0e Fix where under multiple cases
The names the locals were being applied to weren't being updated
properly, so applications of local functions inside case blocks were
sometimes given the wrong arguments. This is one of the few places where
it's hard to keep track of names in the type system! So naturally that'd
be where things go wrong I suppose...
2020-04-09 18:47:39 +01:00
Edwin Brady
6e02ffcb28 Local definitions need to be namespaced
It's unlikely, but possible, that there will be a clash otherwise since
the resolved names aren't unique between modules.
2020-04-09 14:06:53 +01:00
Kamil Shakirov
0ea595817a Fix some typos in the tutorial 2020-04-09 13:48:12 +06:00
Edwin Brady
211fc359ca Erase %World for the purpose of newtypes
We never inspect it, so it carries no information - it just needs to be
there as a token to make sure that IO operations run at the right time.
So, IORes can be a newtype now and therefore optimised away.
2020-04-09 00:20:37 +01:00
Edwin Brady
471a47255f newtype optimisation
Data types with one constructor, that has one unerased argument, are
translated to that argument for runtime. This doesn't have a huge effect
on its own, but doing this will expose other optimisations later (e.g.
increasing effect of inlining).
2020-04-08 19:34:37 +01:00
Edwin Brady
1b859fa5b3 Complete specialised definitions
Specialisation happens on the run time case tree, so we need to know
separately which names occur at compile time, and which at run time.
Hence, we now have 'refersToRuntime' in addition to 'refersTo' since
they will be different. (In fact there's more differences, because
there's a lot of metavariable names which are needed at compile time but
erased at run time)
2020-04-07 15:05:06 +01:00
Jan de Muijnck-Hughes
9ad7efd483 Added a travis badge because it's good to have badges... 2020-04-07 13:26:27 +01:00
Ohad Kammar
eac27b6713 Rename TTImp parser combinator ifaceParam to recordParam to better match its function 2020-04-07 09:19:52 +01:00
Ohad Kammar
0fe402107c In record elaboration, refactor helper function jname into a local function
The important building-block here is constructing the parameter
telescope

A minor benefit is that we're not recalculating this telescope
multiple times.
2020-04-07 06:47:19 +01:00
Ohad Kammar
95f887908a During record elaboration, refactor the type of the record into the
where clause

(1) It was calculated twice previously, once in body of `elabRecord`
and once inside `elabAsData`.

(2) It was passed around globally as a parameter despite not changing
in this context.
2020-04-07 06:27:38 +01:00
Ohad Kammar
74fd12a70b Merge branch 'master' of github.com:edwinb/Idris2 into fully-abstract-records 2020-04-07 04:28:27 +01:00
Edwin Brady
620172b430 Remove superfluous line 2020-04-06 22:40:21 +01:00
Edwin Brady
2688f070e5 Add an ipkg for Idris2 as a library
This is step 0 towards pluggable back ends
2020-04-06 22:27:31 +01:00
Edwin Brady
d801d0d9ae Start on specialisation
This identifies calls that need specialising and builds a type, but
there's still work to do to build the specialised function.
2020-04-06 22:27:31 +01:00
Edwin Brady
2a81bd9fc3 Syntax for flagging arguments to specialise
We'll use this for specialising interfaces in particular, and eventually
for more partial evaluation. (Semantics not yet implemented)
2020-04-06 22:27:31 +01:00