purescript / purescript-prelude

The PureScript Prelude
BSD 3-Clause "New" or "Revised" License
163 stars 88 forks source link

Test code using AlmostEff is subject to dead code elimination #304

Open anttih opened 1 year ago

anttih commented 1 year ago

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 commented 1 year ago

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