* 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>
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.
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).
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.