I think I've got a pretty good idea of the circumstances that make
unsafePerformIO not unsafe. For instance, I would imagine it would be
safe to wrap unsafePerformIO around the following C function:
int myfunc(int i) {
int[256]arr;
for (int j=0; j256; j++)
arr[j] = i+j;
int
If this is true, then is it equivalently safe to wrap the following
Haskell action in unsafePerformIO:
myFunc i =
do arr - newArray (0,255) 0
mapM_ (\j - writeArray arr j (i+j)) [0..255]
foo - newIORef 0
mapM_ (\j - readArray arr j = modifyIORef foo (+j))
I'm curious exactly what is safe and what is unsafe to wrap
unsafePerformIO around when it comes to FFI calls.
Here's a simple test:
Could you imagine an alternative implementation of the same API in
pure Haskell? (Don't consider efficiency or effort required to write
the
Hal Daume [EMAIL PROTECTED] writes:
I'm curious exactly what is safe and what is unsafe to wrap
unsafePerformIO around when it comes to FFI calls.
Here's a simple test:
Could you imagine an alternative implementation of the same API in
pure Haskell? (Don't consider efficiency or
That's a nice succinct way to describe it. Another way, which boils
down to the same thing but which is a little more concrete, is to
ask:
- Does the function's result depend only on the values of its
arguments?
I have two problems with this alternative test:
1) It is sometimes
That's a nice succinct way to describe it. Another way, which boils
down to the same thing but which is a little more concrete, is to
ask:
- Does the function's result depend only on the values of its
arguments?
I have two problems with this alternative test:
1) It is
Hal Daume [EMAIL PROTECTED] writes:
I'm curious exactly what is safe and what is unsafe to wrap
unsafePerformIO around when it comes to FFI calls.
Here's a simple test:
Could you imagine an alternative implementation of the same API in
pure Haskell? (Don't consider efficiency or effort
Hal Daume [EMAIL PROTECTED] writes:
I'm curious exactly what is safe and what is unsafe to wrap
unsafePerformIO around when it comes to FFI calls.
Here's a simple test:
Could you imagine an alternative implementation of the same API in
pure Haskell? (Don't consider efficiency or effort