[Haskell-cafe] Is it usual to read a Maybe (IORef a) ?
minh thu
noteed at gmail.com
Wed Sep 3 08:37:58 EDT 2008
2008/9/3 Bulat Ziganshin <bulat.ziganshin at gmail.com>:
> Hello minh,
>
> Wednesday, September 3, 2008, 2:09:38 PM, you wrote:
>
>> I'd like to write a data structure to be used inside the IO monad.
>> The structure has some handles of type Maybe (IORef a),
>> i.e. IORef are pointers and the Maybe is like null pointers.
>
> i've not used this but overall it seems like a correct way to emulate
> NULL. the whole question is that you probably still think C if you
> need NULL pointers at all :)
Maybe, I'm adapting some C++ code...
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).
Thanks,
Thu
More information about the Haskell-Cafe
mailing list