Commit Graph

963 Commits

Author SHA1 Message Date
Matus Tejiscak
ab04e95ce7 Specialise dotted namespaces as lexemes. 2020-04-17 20:08:56 +02:00
Matus Tejiscak
7ddf1b9818 Use an arrow for record fields. 2020-04-17 01:34:19 +02:00
Matus Tejiscak
86d308da12 Fix names of projections. 2020-04-17 01:04:48 +02:00
Matus Tejiscak
e8166c2dc8 Fix schName. 2020-04-17 00:50:38 +02:00
Matus Tejiscak
ef826ff45c Use RF names for record projections. 2020-04-17 00:44:53 +02:00
Matus Tejiscak
4b986e8b61 Fix record dot syntax parser. 2020-04-17 00:35:39 +02:00
Matus Tejiscak
ca1ef8a882 Implement record dot syntax as Idris sugar. 2020-04-17 00:21:12 +02:00
Matus Tejiscak
10f9d02ecd Implement dot record syntax. 2020-04-16 23:37:45 +02:00
Matus Tejiscak
801da788ed Add the RecordProjection lexeme. 2020-04-16 22:47:21 +02:00
Edwin Brady
40980786e1 Ignoring the World is inadvisable
If IO operations don't return an updated world token, the inliner might
think they're not used at all. So if this turns out to be an overhead,
we'll have to work out another way of eliding it.
2020-04-16 13:39:55 +01:00
Edwin Brady
b665e6afbf Another small inlining improvement
Remove unused lets, and batch resolution of de Bruijn indices in case
branches
2020-04-15 23:59:54 +01:00
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
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
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
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
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
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
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
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
Edwin Brady
1c4b558b26
Merge pull request #271 from ohad/bugfix-269
Bugfix #269
2020-04-06 22:27:19 +01:00
Edwin Brady
3b07afc601
Merge pull request #268 from gallais/interactive-test
[ new ] interactive test runner
2020-04-06 22:12:15 +01:00
Edwin Brady
e383c2793d
Merge pull request #265 from then0rTh/patch-1
fix typo in docs/tutorial/typesfuns.rst
2020-04-06 22:02:40 +01:00
Edwin Brady
36897138db
Merge pull request #261 from gallais/resugar
Resugar `Nat` literals
2020-04-06 21:58:14 +01:00
Edwin Brady
8beeb6ee5a
Merge pull request #260 from ska80/tutorial/idris-prompt
Update Idris prompt in the tutorial
2020-04-06 21:56:27 +01:00
Edwin Brady
db409e29fe
Merge pull request #259 from gallais/cleanup-lexer
A little cleanup
2020-04-06 21:56:16 +01:00
Ohad Kammar
f7dca2ba7d minor: Fix whitespace 2020-04-06 17:36:09 +01:00
Ohad Kammar
b44619e7a8 Replace redundant <- notation with let
Following @gallais's [review](https://github.com/edwinb/Idris2/pull/271#pullrequestreview-388352322)
2020-04-06 16:43:17 +01:00
Ohad Kammar
fbf82eaf0b Bugfix #269
Make desugaring/elaboration of interfaces, interface implementations,
records, and parameter blocks take into account the pragma
`%unbound_implicits off`.

Main changes:

(a) Execute the pragma also during desugaring
(b) Check whether `isUnboundImplicits` is on at each desugaring step

Alternatives I didn't take:

(1) Changing `findBindableNames` to effectfully check the flag.

  Rationale:
  Apart from turning a pure function into an effectful one, this
  would mean repeatedly calling `findBindableNames`, only to do
  nothing once the flag is read.

(2) Adding another function that takes multiple places (list of terms)
  that might contain bindable names, and before dispatching
  `findBindableNames` on each term, checking the flag.

  Rationale: I didn't want to add another abstraction. (weak
  rationale)

@edwinb @gallais : if you prefer (2), I can do that.
2020-04-06 15:56:48 +01:00
Guillaume Allais
6e2ccb085e [ more ] show the diff in case of mismatch 2020-04-06 11:29:18 +01:00
Guillaume Allais
5ae54488d7 [ new ] interactive test runner 2020-04-06 11:06:19 +01:00
then0rTh
e6fe418a6b
fix typo in docs/tutorial/typesfuns.rst
duplicated word
2020-04-04 22:58:34 +02:00
Guillaume Allais
8cb17de3f9 [ fix ] resugar to drop name prefixes
My first attempt at refolding natural constants led to all names
being printed with their namespace prefixes. This fixes that,
most notably by introducing the massive `mapPTermM` function in
`Idris.Syntax`.
2020-04-03 20:00:59 +01:00
Kamil Shakirov
55b3f880d3 Update Idris prompt in the tutorial 2020-04-03 16:44:12 +06:00
Guillaume Allais
e1aea9fae7 [ new ] resugar Prelude's natural numbers 2020-04-03 00:00:16 +01:00
Guillaume Allais
d92a65c43e [ admin ] add empty default target distinct from clean
Tired of having to rebuild everything because I typed `make` in
the wrong directory.
2020-04-02 22:21:40 +01:00
Guillaume Allais
c3f3fdb224 [ cleanup ] scan
Remove one assert_total by re-using strIndex.
2020-04-02 17:31:15 +01:00
Guillaume Allais
c5903c45e1 [ cosmetic ] various whitespace issues 2020-04-02 17:31:15 +01:00
Guillaume Allais
d433eafa97 [ doc ] various doc comments 2020-04-02 17:31:15 +01:00
Edwin Brady
59503712f3 Add --dumpcases option
Output goes in the same directory as the generated code (so
build/exec/<appname>_app for the Chez back end)
2020-04-02 16:11:10 +01:00
Edwin Brady
8029241458
Merge pull request #256 from gallais/faster-lexer
[ performance ] rewrite-free concatMap
2020-04-02 16:11:02 +01:00
Edwin Brady
f85e1f62b1
Merge pull request #255 from ziman/exec-cwd
Don't clobber CWD in `--exec`
2020-04-02 16:09:16 +01:00