
Daniel Cartwright
in GHC.Prim, there is a primitive 'touch#'. It seems that it is used to keep pointers alive, and takes something of any runtime representation, and a State# RealWorld, but there's really no documentation on it, so my idea of what it does is just a guess. Can anyone explain what exactly it does?
Technically I think touch# is only useful when applied to something with pointer runtime representation. However, you otherwise have nailed it. Note, however, that touch# isn't entirely water-tight since the simplifier can (at least as of GHC 8.2) transform your program in ways that break the liveness guarantee provided by touch#; see #14346 for an example. We have proposed a new primop, with#, to fix this (see #14375). Cheers, - Ben