Quantcast
Channel: Haskell Time Limit on Evaluation - Stack Overflow
Browsing index pages (3 articles)
↧

Haskell Time Limit on Evaluation

Does anyone know of a function that will allow only a certain amount of time to execute a function. Something with a type signature like this.limited::Int->(a->b)->a->IO (Maybe b)I can't...

View Article


Answer by J. Abrahamson for Haskell Time Limit on Evaluation

Using the async package we can race threads.import Control.Applicativeimport Control.Concurrentimport Control.Concurrent.Asynclimited :: Int -> (a -> b) -> a -> IO (Maybe a)limited n f a =...

View Article


Answer by leftaroundabout for Haskell Time Limit on Evaluation

There's a dedicated function from System.Timeout:timeout :: Int -> IO a -> IO (Maybe a)To have it the way you wrote, just uselimited t f x = timeout t $ do let y = f x y `seq` return yRemember...

View Article
Browsing index pages (3 articles)


Latest Images