[Haskell-cafe] do nmergeIO or mergeIO preserve order?

Anatoly Yakovenko aeyakovenko at gmail.com
Tue Mar 10 20:52:37 EDT 2009


> 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


More information about the Haskell-Cafe mailing list