Honestly a pragmatic solution would be to have printing to stderr (debug print, logs, whatever) not be an "effect". then as an added benefit if its context is elided out in an optimization you know.
[1] https://hackage.haskell.org/package/base-4.21.0.0/docs/Debug...
This is bc of non strict eval in Haskell, but still the core is that the lang is designed to not eval stuff when it’s not necessary.
If printing- or logging statements have no effect, the compiler might reorder them or even remove them.
Imagine saying that certain memory stores are allowed to cross a memory barrier operation, you'd completely lose the ability to reason about concurrency around those stores.