[Haskell-cafe] Re: [Haskell] IVars

Conal Elliott conal at conal.net
Mon Dec 10 00:22:24 EST 2007


Thanks.  I don't know for what uses of IVars the difference in
expressiveness is helpful, but now I get that the difference is there.
Cheers,  - Conal

On Dec 9, 2007 2:08 PM, Benja Fallenstein <benja.fallenstein at gmail.com>
wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071209/2e97b973/attachment-0001.htm


More information about the Haskell-Cafe mailing list