9 Dec 23:08
Re: Re: [Haskell] IVars
Benja Fallenstein <benja.fallenstein <at> gmail.com>
2007-12-09 22:08:18 GMT
2007-12-09 22:08:18 GMT
Hi Conal, On Dec 9, 2007 6:09 PM, Conal Elliott <conal <at> conal.net> wrote: > > readIVar' :: IVar a -> a > > readIVar' = unsafePerformIO . readIVar > > > so, we do not need readIVar'. it could be a nice addition to the > libraries, maybe as "unsafeReadIVar" or "unsafeReadMVar". > > The same argument applies any to pure function, doesn't it? For instance, a > non-IO version of succ is unnecessary. My question is why make readIVar a > blocking IO action rather than a blocking pure value, considering that it > always returns the same value? >From the rest of Marc's post, I understood the point to be that readIVar lets you do something that readIVar' does not let you do: block until the IVar is written, then continue *without* first evaluating the thunk in the IVar to WHNF. I haven't used IVars myself, so this isn't informed by hands-on experience, but it does sound sensible to me that "block until the IVar has been written" and "evaluate the thunk to WHNF" should be separable. All the best, - Benja
RSS Feed