purescript-prelude icon indicating copy to clipboard operation
purescript-prelude copied to clipboard

Test code using AlmostEff is subject to dead code elimination

Open anttih opened this issue 1 year ago • 1 comments

The type

type AlmostEff = Unit -> Unit

causes code that uses it to be removed when compiling using the backend-optimizer. This is problematic when implementing a new backend where the backend-optimizer is of great benefit.

I suggest we replace the use of AlmostEff with just enough Effect to prevent this from happening.

Even if not using the backend-optimizer or somehow making it possible to prevent dead code elimination I think it would still be better not to use Unit -> Unit as the type in the tests.

anttih avatar Jul 11 '23 16:07 anttih

I should clarify, it's that the backend-optimizer sees Unit -> Unit as a pure function and any bind seems to be doing nothing.

anttih avatar Jul 11 '23 16:07 anttih