
Ryan Ingram wrote:
As long as the FFI calls don't make destructive updates to existing matrices, you can do what you want.
For example, assuming you have:
-- adds the second matrix to the first & overwrites the first matrixAddIO :: MatrixIO -> MatrixIO -> IO ()
-- creates a new copy of a matrix matrixCopyIO :: MatrixIO -> IO MatrixIO ...
Well as you point out there is an efficiency issue if we need to copy matrices all of the time in order to insure 'referential transparency'. Moreover I manage my matrices on a stack in C, since it makes it easy to handle memory allocation and deallocation. The stack configuration tends to be highly fluid so there are always side effects going on. Right now my Matrix type wraps the index from the bottom of the Matrix stack into the IO monad. I was just wondering if there was any obvious way to force an IO action to execute only once, since now each reference to the action IO causes it to execute again. -- View this message in context: http://www.nabble.com/Sequencing-Operations-in-a-Monad-tf4446047.html#a12686... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.