Commit Graph

235 Commits

Author SHA1 Message Date
Edwin Brady
c197c0f777 Update Buffer+File libraries
Adding primitives - it's useful to distinguish between 32 bit and 64 bit
integers when writing to buffers.
2020-05-19 16:06:05 +01:00
Edwin Brady
ba9f14a18c Don't collapse empty lines in 'lines' 2020-05-19 10:44:16 +01:00
Edwin Brady
a130952928 Switch buffers back to scheme FFI
It's just easier to deal with the memory management! But we should do
something more flexible here later.
2020-05-17 22:49:41 +01:00
Edwin Brady
463f1b3233 Add foldlM
Needed for self hosting, and probably ought to be in the prelude by the
usual rule of thumb
2020-05-17 15:23:05 +01:00
Edwin Brady
1acbf1b67e Add Show for Either 2020-05-17 14:51:27 +01:00
Edwin Brady
a302be38f4 Add missing export modifier to ExitCode 2020-05-17 13:08:30 +01:00
Edwin Brady
4c35210025
Merge pull request #370 from ska80/fix-makefiles
Refactor makefiles
2020-05-16 17:34:51 +01:00
Edwin Brady
79d52c5207 Switch to List Char for the lexer
Surprisingly, this doesn't affect performance - it shows up as about the
same in the profile. But more importantly, it ports more directly to
Idris 2, which can't guarantee that 'strTail' doesn't allocate at
runtime, so using a List Char here is much more efficient.

This probably points to the need for better string primitives. Later...
2020-05-16 16:30:51 +01:00
Edwin Brady
560449e087 Check bounds on substring
Fixes #379
2020-05-16 13:50:37 +01:00
Edwin Brady
debe5f6fc3 Add chmod to System.File
Idris 2 needs it - Windows probably needs something else (patches for
Windows support will be very much welcomed!)
2020-05-16 13:02:48 +01:00
Edwin Brady
263d5fa3a1 More system functions
exit, and getting the whole environment
2020-05-16 13:02:48 +01:00
Edwin Brady
34802b9304 Add some Strings functions
strM for nicer matching on head and tail, and functions for parsing
numbers
2020-05-16 13:02:48 +01:00
Edwin Brady
21507e64f3 Some Racket CG fixes
libc needs a version number, and we need to make sure we're not
generating FFI definitions more than once
2020-05-15 12:43:31 +01:00
Edwin Brady
dc67515611 Fix and test directory code 2020-05-14 12:40:48 +01:00
Kamil Shakirov
0e7e05382a Merge branch 'master' into fix-makefiles 2020-05-13 23:37:40 +06: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
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
Kamil Shakirov
982629509b Merge branch 'master' into fix-makefiles 2020-05-13 16:25:15 +06:00
Kamil Shakirov
2ad471a5e3 Refactor makefiles to use some common options 2020-05-13 16:23:07 +06: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
Kamil Shakirov
8261b361e0 Merge branch 'master' into fix-makefiles 2020-05-13 09:05:29 +06: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
Kamil Shakirov
1c8036dc58 Fix building shared libraries with correct extensions 2020-05-12 20:34:49 +06: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
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
16f6a256d8 Convert buffers to new FFI 2020-05-11 18:10:08 +01: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
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
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
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
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
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
Rohit Grover
edb063eb50 Add System.Clock to fetch current time for various clock types. 2020-05-09 17:21:23 +12:00
Rohit Grover
a190408aa1 add srand to allow setting the random seed 2020-05-07 21:41:04 +12:00
Rohit Grover
834ae95256 introduce utilities rndFin and rndSelect 2020-05-07 18:01:35 +12:00
Rohit Grover
dcd19a5966 rewrite let statements according to style conventions 2020-05-07 10:46:39 +12:00
Rohit Grover
2fc589aa76 remove a couple of trailing wheres 2020-05-07 10:08:55 +12:00
Rohit Grover
c8e4210289 relocating System/Random.idr under libs/contrib 2020-05-07 10:06:13 +12:00
Rohit Grover
7cfb3419cb Add System.Random 2020-05-06 11:26:58 +12:00
Edwin Brady
30b609d55f readFile needs a newline
This isn't strictly right yet (there should be no newline on the last
lie if there was no newline in the input file) but it puts the behaviour
back to what it was before fGetLine was changed to discard it.

This needs revisiting...
2020-05-04 21:05:51 +01:00
Matus Tejiscak
b34d275705 Make SortedMap traversable. 2020-04-29 09:10:32 +02:00
Matus Tejiscak
633f51c2f4 Make Traversable (Vect k) public export. 2020-04-29 08:59:00 +02:00
Matus Tejiscak
b53489324e Unify names. 2020-04-29 08:54:37 +02:00