touch# primitive

Ben Lippmeier benl at
Tue Sep 18 20:54:25 UTC 2018

> On 19 Sep 2018, at 1:07 am, Daniel Cartwright <chessai1996 at> wrote:
> 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?

It’s used to place a dependency on a computed value, to prevent the GHC simplifier from moving the binding that computes it around. This is sometimes helpful when writing array fusion systems.

I mentioned it briefly in <>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list