
On 02.11 22:29, Peter Simons wrote:
I see you point. It is obvious that an implementation with two forkIOs is probably slower than an implementation with one. I would love to implement timeout the way you did, but my problem is that it doesn't feel right to depend on Data.Typeable in Control.Concurrent. I don't want to define a new dynamic exception type in that module.
Data.Typeable is only used for the non-Maybe variabts of the functions. And Control.Concurrent already uses Data.Typeable: Control.Concurrent <- Control.Concurrent.MVar C.C.MVar <- Control.Exception C.Exception <- Data.Dynamic Data.Dynamic <- Data.Typeable
One solution could be to move timeout to a different module. Do you have a suggestion? Where would you put your code?
Control.Concurrent.TimeOut - also do timeouts make sense for implementations only supporting co-operative concurrency?
..., forces the programmer to deal with a timeout condition in-place. My impression is that code reliability is furthered by making error conditions explicit, so I tend to prefer that kind of signature. It is not a strong preference, however.
I just provided both Maybe and non-Maybe and let the programmer select the one they prefer. - Einar Karttunen