[Haskell-cafe] so how does one convert an IO a into an a ?

2004-07-08 Thread John Kozak
The root problem is that random number generation is inherently stateful, and so the familiar imperative idioms don't translate directly into a pure functional language. In a C-like language, each invocation of rand() mutates a secret piece of state lurking off-stage; pure functional code doesn't

[Haskell-cafe] some newbie FFI questions

2004-07-01 Thread John Kozak
I'm trying to experiment with image processing in haskell (with which I haven't much experience). I've written some FFI code to talk to the ImageMagick library which provokes a few questions (environment is ghc 6.2.1 on debian): 1. Speed: I'm reading in a 2000x1500 pixel image, and have defined

Re: [Haskell-cafe] some newbie FFI questions

2004-07-01 Thread John Kozak
Alastair Reid writes: [...] Overall, I'd probably use an unboxed Haskell array. This would let you get a memory layout (and memory consumption) close to the normal C layout. I'd use access functions to hide the boxing/unboxing and I'd write some map/fold/scan-like functions to