On 19 Sep 2018, at 1:07 am, Daniel Cartwright <chessai1996@gmail.com> 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 
http://benl.ouroborus.net/papers/2011-stencil/stencil-haskell2011.pdf

Cheers,
Ben.