module M (foo, bar) where import Data.Array.Base import Data.Array.IO newListArray1 :: (Int,Int) -> [Int] -> IO (IOUArray Int Int) newListArray1 (l,u) es = do marr <- newArray_ (l,u) let n = safeRangeSize (l,u) f x k i | i == n = return () | otherwise = unsafeWrite marr i x >> k (i+1) foldr f (const (return ())) es 0 -- foldr f (\ !_ -> return ()) es 0 return marr {-# INLINE newListArray1 #-} -- fusion occurs with [0..] foo :: (Int,Int) -> IO (IOUArray Int Int) foo bnds = newListArray1 bnds [0..] -- no fusion bar :: (Int,Int) -> [Int] -> IO (IOUArray Int Int) bar bnds xs = newListArray1 bnds xs