[Haskell-cafe] Is it usual to read a Maybe (IORef a) ?

Jake Mcarthur jake.mcarthur at gmail.com
Fri Sep 5 00:40:16 EDT 2008

On Sep 4, 2008, at 12:50 PM, minh thu wrote:

>> I'd have thought you wanted "IORef (Maybe Thing)", which says that  
>> the
>> pointer always exists, but may not point to anything.  On the other  
>> hand
>> "Maybe (IORef Thing)" says that the pointer may or may not exist.
> Yes, someone else said it too. But you saiy that regarding the  
> pointer. If you
> look at the thing the pointer (if any) points at, what's the  
> difference ?
> Either there is none : Nothing or IORef Nothing, or there is one :
> Just (IORef 5)
> or IORef (Just 5).

There is still a difference. With Maybe (IORef a), the nothingness is  
expressed only locally, but with IORef (Maybe a), the nothingness can  
be shared and mutated by any other IORefs that point to it as well.

- Jake McArthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080904/b9aa713c/attachment.htm

More information about the Haskell-Cafe mailing list