
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 :)
readHandle :: Maybe (IORef a) -> IO (Maybe a)
Are there any related functions in the standard libraries ?
readHandle = maybe (return Nothing) (fmap Just . readIORef) or you can add your own primitive: liftNULL op = maybe (return Nothing) (fmap Just . op) readHandle = liftNULL readIORef -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com