
On Sat, 2011-01-01 at 13:59 -0500, Brandon S Allbery KF8NH wrote:
On 12/23/10 20:57 , Thomas Schilling wrote:
I also find the name 'forkOnIO' extremely confusing. Without reading the docs it seems to imply that a thread is created on IO, i.e., if I/O happens. This makes no sense, and is of course not what's happening. However, I assume you chose it because forkIOOn looks a bit weird. In that case, why not use forkThreadOn, and in a separate proposal change forkIO to forkThread (or just fork).
+1 The name "forkIO" always seemed a bit odd to me; aren't threads pretty much constrained to IO anyway?
Depends on what you understand by thread:
import Control.DeepSeq import Control.Parallel import Control.Seq
mergeSort :: (NFData a, Ord a) => [a] -> [a] mergeSort [] = [] mergeSort [x] = [x] mergeSort xs = let (ys, zs) = foldr (\e (a, b) -> (e:b, a)) ([], []) xs merge xs [] = xs merge [] ys = ys merge s@(x:xs) t@(y:ys) | x < y = x : merge xs t | otherwise = y : merge s ys ys' = mergeSort ys `using` rdeepseq zs' = mergeSort zs `using` rdeepseq in ys' `par` zs' `par` merge ys' zs'
main = print $ mergeSort ([1..100] :: [Int])
(Code was not written to be nice, efficient or even correct but to illustrate the point.) Regards