Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread kahl
> > It's just annoying that turning a partial function into a total one > looses so much strictness, since it prevents strictness propagation. Of > course, this is easily solved using a `strict' Maybe: > data Perhaps a = Just' !a | Nothing' > > Are other people experiencing the same thin

Re[2]: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Bulat Ziganshin
Hello Mirko, Friday, May 12, 2006, 4:42:02 PM, you wrote: >> PS: I am still curious: does threadDelay use >> the wall clock or the per-process clock (CPU time)? > I think it uses wall clock time. Proof: >> And regardless of the answer - how could one obtain >> the opposite behaviour? (I don't f

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Mirko Rahn
PS: I am still curious: does threadDelay use the wall clock or the per-process clock (CPU time)? And regardless of the answer - how could one obtain the opposite behaviour? (I don't find this discussed in the visible docs. Or am I missing something?) I think it uses wall clock time. Proof: *N

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Johannes Waldmann
Arjen van Weelden wrote: > Personally, I'm often surprised by the laziness introduced by Maybe. Yes. That's why I chose the return type Boolean in my original post, and I included the remark on "Just x with x in whnf". Mirko used a list, where whnf is not enough. PS: I am still curious: does th

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Arjen van Weelden
Donald Bruce Stewart wrote: rahn: Donald Bruce Stewart wrote: watchdogIO :: Int -- milliseconds -> IO a -- expensive computation -> IO a -- cheap computation -> IO a I'm not satisfied by the given function completely. Suppose the wrappers for pure c

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Donald Bruce Stewart
rahn: > Donald Bruce Stewart wrote: > > >watchdogIO :: Int -- milliseconds > > -> IO a -- expensive computation > > -> IO a -- cheap computation > > -> IO a > > I'm not satisfied by the given function completely. Suppose the wrappers > for pure comput

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Mirko Rahn
Donald Bruce Stewart wrote: watchdogIO :: Int -- milliseconds -> IO a -- expensive computation -> IO a -- cheap computation -> IO a I'm not satisfied by the given function completely. Suppose the wrappers for pure computations watchdog1 :: Int

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Johannes Waldmann
Donald Bruce Stewart wrote: > forkIO + killThread && threadDelay OK that's nice and solves my problem. Thanks! Is the delay measured on the wall clock or on the user (per-process) clock? -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- http://www.imn.htwk-leipzig.de/~waldmann/ ---

Re: [Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Donald Bruce Stewart
waldmann: > What is the idiomatic way to say in (ghc) Haskell: > "run this computation for at most x seconds" > (e. g. it returns Boolean; imagine a primality test) > so I want something :: Int -> a -> Maybe a > with the guarantee that the result is > Just x with x in whnf, or Nothing. > I gu

[Haskell] timing/timeout (how to express that in Haskell)

2006-05-12 Thread Johannes Waldmann
What is the idiomatic way to say in (ghc) Haskell: "run this computation for at most x seconds" (e. g. it returns Boolean; imagine a primality test) so I want something :: Int -> a -> Maybe a with the guarantee that the result is Just x with x in whnf, or Nothing. I guess one answer is "that'