Re: Top level mutable data structures problem

A slight tangent, (and not GHC specific) so I have put this reply in the cafe. a way to get mutable data outside the IO monad occurs to me. If a file is a mutable data type outside of Haskell, we have hGetContents... which can be implemented with unsafeInterleaveIO, rather than unsafePerformIO. hGetContents lets you read a file from outside the IO Monad. The same applies to hGetChannel. What if there was a way to write in the same way? Say you write a function that reads lazily from a list ... you could then have: main :: IO () ... a <- hGetChannel channel hPutChannel (f a) -- this lazily puts the list to the channel. At the other end of the channel we have a state storage thread, which obeys commands sent over the output channel (read x, write y etc...) You can then write a function, which prepends the next instruction to the output list, and reads data from the input list hence manipulates the state. (the sequence of IO operations is preserved by the lists) Keean.
participants (1)
-
MR K P SCHUPKE