+-- Link a bunch of BCOs and return them + updated closure env.
+linkSomeBCOs :: ItblEnv -> ClosureEnv -> [UnlinkedBCO]
+ -> IO (ClosureEnv, [HValue])
+linkSomeBCOs ie ce_in ul_bcos
+ = do let nms = map nameOfUnlinkedBCO ul_bcos
+ hvals <- fixIO
+ ( \ hvs -> let ce_out = addListToFM ce_in (zipLazily nms hvs)
+ in mapM (linkBCO ie ce_out) ul_bcos )
+ let ce_out = addListToFM ce_in (zip nms hvals)
+ return (ce_out, hvals)
+ where
+ -- A lazier zip, in which no demand is propagated to the second
+ -- list unless some demand is propagated to the snd of one of the
+ -- result list elems.
+ zipLazily [] ys = []
+ zipLazily (x:xs) ys = (x, head ys) : zipLazily xs (tail ys)