Open noughtmare opened 3 years ago
I have a better solution, we can rewrite Ctl
into a monad transformer CtlM
which can run IO
actions properly. Then you only need one unsafePerformIO
at the top level in runCtl
.
I have been able to make it work, but I have to clean up my code a bit. Expect a pull request soon.
Update: the change significantly affects some benchmarks, so I am investigating further. But maybe the microbenchmarks are also not representative of real-world scenarios w.r.t. inlining and specialization as Alexis King's talk "Effects for Less" showed.
@noughtmare I tried to reproduce this with the current HEAD and it works as intended. Can your confirm that?
If I compile with optimizations then I can still reproduce it.
E.g. the program:
Prints (when compiled with
-O
):I think that this is due to common sub-expression elimination. First the code above gets turned into something like:
And common sub-expression elimination transforms that to:
A simple solution seems to be to mark
perform
NOINLINE
, but that probably affects performance.