Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bounded computation in Haskell

Tags:

haskell

ghc

Is there any way in Haskell (using GHC if it matters, for code that needs to run on Linux and Windows) to perform bounded computation? That is, "compute the result of this function if it is feasible to do so, but if the attempt has used more than X CPU cycles, Y stack space or Z heap space, and still not done, stop and return an indication that it was not possible to complete the computation"?

like image 425
rwallace Avatar asked May 27 '12 06:05

rwallace


1 Answers

System.Timeout.timeout :: Int -> IO a -> IO (Maybe a)

http://lambda.haskell.org/hp-tmp/docs/2011.2.0.0/ghc-doc/libraries/base-4.3.1.0/System-Timeout.html#v:timeout

like image 123
Louis Wasserman Avatar answered Sep 29 '22 18:09

Louis Wasserman