import Control.Monad.ST
import Data.STRef

sum_ :: STRef s Double -> Double -> Double -> ST s Double -> ST s Double
sum_ ref_i lo hi term = sum <$> mapM ((>> term) . writeSTRef ref_i) [lo .. hi]

foo :: Double
foo =
  runST $
  do i <- newSTRef undefined 
     sum_ i 1 100 $ recip <$> readSTRef i

main :: IO ()
main = print foo