[Haskell-cafe] What's the best way to give up?

Christopher Lane Hinson lane at downstairspeople.org
Sat Sep 6 10:16:43 EDT 2008


>> a -> IO (Either a a ) and use getCPUTime.
>>
>> Is there a standard way to do this?  Can you think of another way to do it?
>
> I don't know, but this seems relevant:
> http://www.haskell.org/pipermail/haskell-cafe/2005-October/011946.html
>
> I'd make a generic (i.e. higher-order) function that handles the
> timeout for any computation. i.e.
>
> timeout :: (a -> b) -> Int -> a -> IO (Maybe b)

http://haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout

Perhaps this is for not so much for pure computations as hanging when 
connecting to nonresponsive servers, although I also use it in a case 
where buggy long-running code could frustrate the responsiveness of 
unrelated processes..

--Lane


More information about the Haskell-Cafe mailing list