Export !# from GHC.Arr?
Motivation
For avoiding space leaks, it can be useful to eagerly index into a non-strict array, but without eagerly evaluating the thunk at that location. !#
is used internally to the GHC.Arr
module for this purpose.
My particular use case is that I'm implementing CBN normalization by evaluation, using an interpreter that passes around environments as arrays of thunks. By preprocessing the lambda terms to find variable usage info, I can avoid space leaks by using !#
to create trimmed environments containing only those thunks that will be used.
Proposal
It might be nice to export !#
from GHC.Arr
as a public function. For symmetry, it would make sense to export unsafeAt#
along with it.
It's possible to still get this functionality by using GHC.PrimopWrappers.indexArray#
directly, but it would certainly be more convenient to have access to !#
or unsafeAt#
.