Hacker News new | ask | show | jobs
by maleldil 270 days ago
This is similar to what Haskell has with trace[1]. It pretends to be a pure function (so it doesn't need the IO monad), but prints to stderr.

[1] https://hackage.haskell.org/package/base-4.21.0.0/docs/Debug...

1 comments

And, just like tfa alludes, it is awkward because of laziness; in non trivial scenarios it can be quite surprising how your trace isn’t tracing.

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.