
10 Mar
2009
10 Mar
'09
8:52 p.m.
I would also consider it bad style to be fully polymorphic in this case, as you require polymorphic seq, which is evil (though I don't have the space to argue this right now :-). Unamb would be bad style, also, since your semantics are nondeterministic and so you wouldn't meet the precondition. Surely your result would have to be in IO. ("amb" would be okay)
what do you mean by fully polymorphic?
Here is how I would do it:
chooseIO :: [IO a] -> IO [a] chooseIO xs = do chan <- newChan let eval io = forkIO (io >>= writeChan chan) forkIO $ mapM_ eval xs getChanContents chan
Cool, thanks, thats basically what iw as thinking to. Anatoly