[Haskell-cafe] What's the best way to give up?
arnarbi at gmail.com
Sat Sep 6 09:05:59 EDT 2008
On Sat, Sep 6, 2008 at 13:30, David F. Place <d at vidplace.com> wrote:
> If there is a solution, it finds it in a few seconds. If there is no
> solution, it goes away for days proving that. So, I'd like to give up on it
> if it doesn't return in a few seconds. I can think of several ways of
> doing that. I could keep a tally of the number of variable assignments and
> give up when it reaches an impossibly huge number. I could change the type
> 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:
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)
More information about the Haskell-Cafe