(a ! b) ! a ! b spec guess f a = | unsafeIsEvaluated a = f a | otherwise = speculation `par` if guess == a then speculation else f a where speculation = f guess 133݄31༵
(a ! b) ! a ! b spec guess f a = | unsafeIsEvaluated a = f a | numCapabilities == 1 = f $! a | otherwise = speculation `par` if guess == a then speculation else f a where speculation = f guess 133݄31༵
(a ! STM b) ! a ! STM b specSTM mguess f a = a `par` do guess ← mguess result ← f guess unless (guess == a) retry return result `orElse` f a 133݄31༵
(a ! STM b) ! a ! STM b specSTM mguess f a = do sparks ← unsafeIOToSTM numSparks if sparks < numCapabilities then a `par` do guess ← mguess result ← f guess unless (guess == a) retry return result `orElse` f a else f $! a 133݄31༵
b) ! (a ! b ! b) ! b ! f a ! b foldr g f z = extractAcc . F.foldr mf (Acc 0 z) where mf a (Acc n b) = Acc (n + 1) (spec (g n) (f a) b) data Acc a = Acc {-# UNPACK #-} !Int a extractAcc (Acc _ a) = a 133݄31༵
(Int ! a) ! (a ! f b) ! t a ! f (t b) traverse g f xs = runAccT (T.traverse go xs) 0 where go a = AccT $ λi# ! acc (i# +# 1#) (spec (g (I# i)) f a) newtype AccT m a = AccT { runAccT :: Int# ! Acc (m a) } 133݄31༵
(a ! b ! b) ! b ! [a] ! [b] scanr g f z = map extractAcc . L.scanr mf (Acc 0 z) where mf a (Acc n b) = let n’ = n + 1 in Acc n’ (spec (g n’) (f a) b) 133݄31༵