Here are some pragmas and some imports:
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad.ST
import Data.Array.ST
import Data.Array
<
As you already hint at in the title of your post, the problem has to do with runSTArray having a polymorphic type of rank 2.
runSTArray :: Ix i => (forall s. ST s (STArray s i e)) -> Array i e
With
elems :: Ix i => Array i e -> [e]
and
($) :: (a -> b) -> a -> b
writing runSTArray $ ... means that the type variable a in the type schema of ($) needs to be instantiated with a polymorphic type rather than a monomorphic type. This requires so-called impredicative polymorphism. How GHC implements impredicative polymorphism is explained in the ICFP 2008 paper by Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones: FPH : First-class Polymorphism for Haskell. The bottom line is that while FPH often gives you the behaviour that you expect, typeability is sometimes not preserved under simple transformations like the ones you describe in your question: see Section 6.2 of the aforementioned paper.