Re: unsafePerformIO around FFI calls

2002-07-23 Thread Hal Daume III
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

RE: unsafePerformIO around FFI calls

2002-07-23 Thread Simon Marlow
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))

Re: unsafePerformIO around FFI calls

2002-07-10 Thread C.Reinke
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

RE: unsafePerformIO around FFI calls

2002-07-09 Thread Simon Marlow
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

Re: unsafePerformIO around FFI calls

2002-07-09 Thread Alastair Reid
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

RE: unsafePerformIO around FFI calls

2002-07-09 Thread Simon Marlow
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

Re: unsafePerformIO around FFI calls

2002-07-08 Thread Alastair Reid
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

Re: unsafePerformIO around FFI calls

2002-07-08 Thread Alastair Reid
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