Commit Graph

1220 Commits

Author SHA1 Message Date
Edwin Brady
87c54caa27 Do compiling/inlining per module
Compiled and inlined code is now written to the ttc, to save having to
compile everything at the end even if some definitions don't need
recompiling.
2020-05-14 11:42:09 +01:00
Edwin Brady
18b6449657 Match on names for typecase
This is instead of generating unique integer tags when generating IR to
pass to a back end. The reason is that this way requires whole program
compilation - to make sure the tags are unique - but it would be
beneficial to build the IR when checking a module, not all at once at
the end.
So, this is to support separate compilation.
It does mean the API for IRs has changed slightly - tags are now Maybe
Int rather than Int. If a tag is 'Nothing' you should generate something
to match on based on the name. The Scheme back ends currently do this
just by printing the string.

Matching on types is likely to be rare, but if this does turn out to be
a bottleneck, a backend can generate unique ids at that point, which is
a lot cheaper than doing it before building, inlining, optimising, etc.
2020-05-13 20:10:41 +01:00
Edwin Brady
f5962e1ea4 Update test output 2020-05-13 19:06:22 +01:00
Edwin Brady
a6e7326ab7
Merge pull request #373 from buzden/docs-idiom-brackets-fix
Idiom brackets syntax was fixed in the docs
2020-05-13 13:31:02 +01:00
Edwin Brady
5285b36a4f Update CHANGELOG and CONTRIBUTORS
Trying to keep both up to date - apologies if I'm missed anyone. I got
the list from the git logs, but feel free to edit yourself in or out as
you prefer.
2020-05-13 13:12:41 +01:00
Edwin Brady
68081ed86c Some scheme generation fixes
In racket, importing date and srfi/19 fails. Also some minor edits to
gambit support code.
2020-05-13 12:41:38 +01:00
Edwin Brady
18dff43d2b Move Concurrency.Raw to new FFI 2020-05-13 12:18:21 +01:00
Edwin Brady
9a0608b01f Add idris_crash function
Because sometimes all you can do is give up (e.g. failing to allocate
memory for some crucial thing).
2020-05-13 12:05:00 +01:00
Denis Buzdalov
5088cb621c Idiom brackets syntax was fixed in the docs 2020-05-13 13:39:09 +03:00
Edwin Brady
1b36dd99b1 Move putChar, getChar etc primitives to C
Back ends can still shortcut these and use their own primitives, but
doing things this way gives consistent behaviour between the simple IO
primitives and file IO, and allow us to use stdin/stdout consistently
(e.g. to flush stdout).
This also fixes the behaviour of 'replWith' to be consistent with the
Idris 1 version.
2020-05-13 11:09:05 +01:00
Edwin Brady
a451dcd171 CHANGELOG updates
Noting recent langauge changes for optimisations. Full documentation
still to come.
2020-05-13 00:12:58 +01:00
Edwin Brady
2d1d7be949 Move directory code to C
...and remove the scheme support for it on the way
2020-05-13 00:09:52 +01:00
Edwin Brady
cadd7e1322 Move more support code to C
System mostly calls C now, except for getting command line arguments,
which may be too back end dependent so maybe we should think of another
approach here later.
2020-05-12 23:31:39 +01:00
Edwin Brady
3ab68fb7c8 Add some more file operations
I've also added some windows support headers (taken straight from the
rts/Idris 1) but I have no way to test, and the Makefile doesn't build
them. Please can someone who is familiar with windows fix this? Thanks!
2020-05-12 22:49:58 +01:00
Edwin Brady
38e43f2c17 Move file management to C support library
This removes the need for some external primitives, and allows the
details to be shared between all the backends (plus we don't have to do
things a certain way just because Scheme chooses to)
2020-05-12 22:35:14 +01:00
G. Allais
f72f91c67a
[ fix ] build by installing support before tests (#369) 2020-05-12 15:23:42 +01:00
Edwin Brady
e7d0b33e64 Do another round of inlining, and io_bind
A big cost in IO heavy programs is io_bind, and we can often inline it
away and turn it into just sequencing operations. Things have to be
lined up right to do that though - ideally, case inlining and the
newtype optimisation will know just a little bit more to be able to do
it automatically, but for now, the inliner treats io_bind as a special
case.

Also do another round of inlining, since lots more things can become
inlinable (io_bind especially, becoming fully applied to the %World)
after the first pass.
2020-05-12 11:33:29 +01:00
Edwin Brady
9328579575 Hack for optimising some enumerations
Really this should be generalised to any type that looks like an
enumeration after erasure, but this catches the most common options
quickly.
2020-05-11 18:10:08 +01:00
Edwin Brady
7adb4d3342 Move buffer API to C
It's slightly different wrt to file reading and writing, and now
requires the created buffer to be explicitly freed (since unlike Idris 1
the run time can't be told to manage C values) but this makes the buffer
code more portable by not requiring it to run via scheme.
Performance appears more or less the same as before.
2020-05-11 18:10:08 +01:00
Edwin Brady
e9a6b687f4 Small code generation improvements
Case blocks with single entry + removing unused field names
2020-05-11 18:10:08 +01:00
Edwin Brady
16f6a256d8 Convert buffers to new FFI 2020-05-11 18:10:08 +01:00
Edwin Brady
6681131957 Make a start on C support code
It would be nice to have some common routines that all back ends that
can talk to C can use, rather than relying on Scheme for standard
library code.
2020-05-11 18:10:08 +01:00
Edwin Brady
d2550dc441
Merge pull request #361 from chrrasmussen/avoid-realpath
Update chez016 test to not rely on realpath
2020-05-11 13:09:48 +01:00
Edwin Brady
d173d62b83
Merge pull request #366 from ska80/remove-chicken-cg
Remove remaining traces of Chicken CG
2020-05-11 13:09:20 +01:00
Kamil Shakirov
9691a5a82c Remove remaining traces of Chicken CG 2020-05-11 11:40:03 +06:00
Edwin Brady
b617cae888 Add transformation rules for top level methods
This can be quite effective at removing runtime overhead when just using
an overloaded method directly. It is, however, still quite limited (only
works on top level interfaces, so no inlining of parents, e.g. like X a
=> X (List a), and sometimes generating the transform rules fails for
reasons I haven't worked out yet).

This is experimental, I might change the way this works at any point,
but it's a nice improvement for now.
2020-05-10 20:51:20 +01:00
Edwin Brady
11cbc301d7 Avoid unification in proof search if not needed
Unification works on values, and it may therefore expand a definition
unnecessarily (and probably will, in the most common case that an
argument unifies with a hole)
2020-05-10 20:05:50 +01:00
Edwin Brady
3d598169cf Fix some details of transforms
Need to save as full names and add as resolved names. Also elaborator
needs to know it's elaborating a rule in some places.
2020-05-10 19:19:59 +01:00
Edwin Brady
0dc486a26e Apply transformation rules
I haven't yet worked out a nice way to test these automatically...
Also note that:
- only the types of the LHS and RHS are checked (and must be the same,
like in a normal pattern matching clause) so there's no attempt to
ensure that the rules are "safe". Possibly later, they should require an
equality proof?
- There is no attempt to ensure the rules are confluent or terminating,
but there is a termination threshold on apply the rules (currently set
at 5 cycles, but maybe should be configurable)
2020-05-10 14:27:25 +01:00
Christian Rasmussen
0694b6c0ef Update chez016 test to not rely on realpath 2020-05-09 23:19:38 +02:00
Edwin Brady
0c1e428435 Fix laziness bookkeeping in unification
Need to note we can't add a laziness coercion under 'unifyInvertible',
which is where we unify things under metavariables which are known to
stand for constructor forms. Fixes #360
2020-05-09 19:19:26 +01:00
Edwin Brady
449f29b723 Check and add transform rules
They don't do anything yet though
2020-05-09 18:55:56 +01:00
Edwin Brady
15c6a0d137 Remove chicken back end
(Which was commented out anyway)
Three scheme back ends is enough to maintain, and Gambit does the same
job as chicken (fast startup of the interpreter, generating via C) but
seems to deal with the code Idris generates better.
2020-05-09 13:57:27 +01:00
Edwin Brady
e14f8e1ac9 Add high level syntax for transform rules 2020-05-09 13:27:42 +01:00
Edwin Brady
52db302d35 Improve partial evaluation
Remove restrictions on private names, since we'll need to check and
reduce them in the partially evaluated definition.
2020-05-09 13:27:42 +01:00
Edwin Brady
28de766340 Don't fail on partial evaluation failure
We don't want the entire system to depend on partially evaluating a
definition succeeding (and certainly not before it's properly stable)
2020-05-09 13:27:42 +01:00
Edwin Brady
87da7d1122 Make parameters to statics also static
Even if inferrable from a dynamic - because their value will be the same
every time.
2020-05-09 13:27:42 +01:00
Edwin Brady
572d1746d3
Merge pull request #350 from berewt/findIpkgDepends
--find-pkg load dependencies
2020-05-09 13:12:23 +01:00
Edwin Brady
158b6fb4dc
Merge pull request #347 from ziman/fix-racket
Fix order of arguments in write-string for Racket
2020-05-09 13:10:22 +01:00
Edwin Brady
afa9352dd3
Merge pull request #329 from LibreCybernetics/refactor-identifier-lexer
Refactor identChar into the identLexer to have that definition in one place
2020-05-09 13:09:59 +01:00
Edwin Brady
7e06798ebf
Merge pull request #340 from chrrasmussen/add-nonewtype
Add noNewtype option to data types
2020-05-09 13:09:00 +01:00
Edwin Brady
595093f34e
Merge pull request #358 from rgrover/system.clock
Add System.Clock to fetch current time for various clock types.
2020-05-09 12:57:23 +01:00
Edwin Brady
5a81884d2b
Merge branch 'master' into system.clock 2020-05-09 12:57:10 +01:00
Edwin Brady
600412f9f3
Merge pull request #354 from rgrover/system.random
Add System.Random
2020-05-09 12:54:23 +01:00
Edwin Brady
a7e0f63d16
Merge pull request #353 from ska80/fix-cast-char-string
Fix casting Char to String
2020-05-09 12:53:09 +01:00
Edwin Brady
2cfcea0484
Merge pull request #339 from ziman/traversable-map
Make SortedMap foldable and traversable
2020-05-09 12:50:20 +01:00
Edwin Brady
73223270f4
Merge pull request #337 from ziman/traversable-vect
Export the implementation of `Traversable (Vect k)`
2020-05-09 12:45:41 +01:00
Edwin Brady
833168fe96
Merge pull request #317 from abdelq/gambit
Including a Gambit Scheme backend
2020-05-09 12:39:34 +01:00
Rohit Grover
fa94713a2a minor reorganization and cleanup of Clock.idr 2020-05-09 18:07:20 +12:00
Rohit Grover
5ceee18a36 fix comment describing the UTC clock type 2020-05-09 18:00:35 +12:00