Commit Graph

15 Commits

Author SHA1 Message Date
vfrinken
b1f45f2748
RefC backend improvements (#2425)
* RefC backend improvements

1. OnCollect had the wrong number of arguments. The code creator expects
   3 arguments, but onCollect in prim.h expected 4 arguments. The first of which
   was an erased arguments. That is now fixed.

2. OnCollect did not call `newReference` when creating a new reference to the pointer
   and the freeing function

3. OnCollect and OnCollectAny still had a spurious printf statement

Those issues have been fixed, the test case can be found in
  tests/refc/garbageCollect

4. The IORef mechanism expects that the %World token will be passed around
   consistently. This is not the case. States in Control.App make use of
   IORefs, but the function created from Control.App.prim_app_bind
   had the world token erased to NULL.
   Now, IORefs are managed using a global variable,
   IORef_Storage * global_IORef_Storage;
   referenced in cBackend.h, defined in the created .c file, and set to NULL
   in main();

5. While multithreading and forking is still not supported, compiling a program
   that makes use of Control.App demands a C implementation of prim_fork.
   Files support/refc/threads.c and support/refc/threads.h provide a
   dummy implementation for it, so that Control.App programs compile and run.

A test for these 2 issues is given in tests/refc/issue2424

* format changes

to make the linter happy

* format changes

to make the linter happy

* format changes

to make the linter happy

* spelling mistake braket -> bracket

Co-authored-by: Volkmar Frinken <volkmar@onutechnology.com>
2022-04-27 13:59:32 +01:00
stefan-hoeck
ed9a21f6bc [ new ] support prim__putStr in browser 2021-08-24 03:44:57 +00:00
Stiopa Koltsov
5a351f4e7e Accept HasIO in onCollect functions
Since most functions work with `HasIO`, it is more convenient to
accept `HasIO` in `onCollect` and `onCollectAny`.
2021-07-17 14:42:34 +01:00
Stiopa Koltsov
291823c752 Remove prim__getErrno from Prelude.IO
The function is not used, and it is defined incorrectly.
2021-07-14 03:15:49 +01:00
Nick Drozd
ec438760d9
Simplify some lambdas (#1561) 2021-06-16 15:22:30 +01:00
Robert Wright
2a957a38d9 Add RefC FFI header file support 2021-05-20 14:25:16 +01:00
Ruslan Feizerakhmanov
af7edd72bb [prelude] Add explicit constructor to every interface 2021-05-06 18:32:51 +03:00
Wen Kokke
bd683938bf
Overhaul of concurrency primitives (#968)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2021-02-05 16:16:20 +00:00
Edwin Brady
d4abbfdae2 Add HasLinearIO
Ideally, liftIO would always be linear, but that has lots of knock-on
effects for other monads which we might want to put in HasIO, now that
subtyping is gone. We'll have to revisit this when we have some kind of
multiplicity polymorphism.
2021-01-11 11:24:43 +00:00
Edwin Brady
ad632d825d Remove linearity subtyping
It's disappointing to have to do this, but I think necessary because
various issue reports have shown it to be unsound (at least as far as
inference goes) and, at the very least, confusing. This patch brings us
back to the basic rules of QTT.

On the one hand, this makes the 1 multiplicity less useful, because it
means we can't flag arguments as being used exactly once which would be
useful for optimisation purposes as well as precision in the type. On
the other hand, it removes some complexity (and a hack) from
unification, and has the advantage of being correct! Also, I still
consider the 1 multiplicity an experiment.

We can still do interesting things like protocol state tracking, which
is my primary motivation at least.

Ideally, if the 1 multiplicity is going to be more generall useful,
we'll need some kind of way of doing multiplicity polymorphism in the
future. I don't think subtyping is the way (I've pretty much always come
to regret adding some form of subtyping).

Fixes #73 (and maybe some others).
2020-12-27 19:58:35 +00:00
russoul
3a9b1ac656 Add supporting code 2020-08-25 14:30:57 +03:00
russoul
594105d5ac Eliminate schemeCall from the library 2020-08-24 19:38:29 +03:00
Kamil Shakirov
8544e80076 Use the same naming convention for foreign primitives 2020-08-19 14:05:28 +01:00
russoul
d387c76e9b update stdio docs 2020-08-08 12:49:33 +01:00
Edwin Brady
6a53e0177c Reorganise prelude into multiple files
This is partly to tidy things up, but also a good test for 'import as'.
Requires some internal changes since there are parts of reflection,
unelaboration and a compiler hack that rely on where things are in the
Prelude.
2020-07-12 16:55:48 +01:00