David Roundy wrote:

There are plenty of non-IO reasons to use unsafePerformIO, for which it is
essential. If you want to write haskell code that uses a pointer
(allocated possibly via an FFI C routine), it has to be in the IO monad.
If you know that this pointer doesn't access memory that'll be changed at
random (or by other routines), you can (and *should*) safely use
unsafePerformIO.


Does it? cant you just declare:

import foreign ccall "somefn" somefn :: Ptr Double -> Ptr Double

Also, if you're interested in using weak pointers (for example, to do
memoization), you'll almost certainly need to use unsafePerformIO. Again,
the result can, and should, be encapsulated, so the module that uses
unsafePerformIO exports only pure functions (unless of course, there are
any that actually perform IO).


Don't know about this one, got a short example?

   Keean.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to