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

Paul Johnson paul at cogito.org.uk
Thu Sep 4 13:39:09 EDT 2008


minh thu wrote:
> Do you suggest I use
>
> data Thing = Thing | None
>
> and IORef Thing instead of
>
> data Thing = Thing
>
> and Maybe (IORef Thing) ?
>
> I'm writing a data structure that can hold  Things (and that can be mutated) or
> nothing (there is a hole in the wrapping data).
>
>
>   
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.

Paul.



More information about the Haskell-Cafe mailing list