
Hello, I am in this case, the Cube C struct contains at least two realy big arrays. I wan to modify them in place.
If however always copying the cube is too expensive, then you can take an approach similar to that used in Array or Vector, where Cubes are available in both immutable and mutable forms, with freeze, thaw, unsafeFreeze and unsafeThaw operations connecting the two.
data Cube = Cube ... data STCube s = STCube s ... data IOCube = IOCube ...
Mutable cubes can be modified in place in either the IO or ST Monads.
I like this idea, I looked a t the MVector implementation data MVector s a = MVector {-# UNPACK #-} !Int -- ^ Offset in underlying array {-# UNPACK #-} !Int -- ^ Size of slice {-# UNPACK #-} !(MutableArray s a) -- ^ Underlying array deriving ( Typeable ) type IOVector = MVector RealWorld type STVector s = MVector s I imagine that in my case I can can just define a. data MCube s = MCube (ForeignPtr C'HklBinocularsCube) and then type IOCube = NCube RealWorld I a
-- VIktor. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.