Thanks.  I'm using the function as pure, and so far, so good.  Cheers,  - Conal

On 9/2/07, shelarcy < > wrote:
Hi Conal,

On Wed, 29 Aug 2007 09:42:15 +0900, Conal Elliott <> wrote:
> Is there any reason for imageCreateFromPixelArray to be in IO?  I want to
> use it as a pure function (via unsafePerformIO), and I'm wondering if there
> are any gotchas.   - Conal

I think it's just implementation reason.

imageCreateFromPixelArray create pixelBuffer and set pixelBuffer
color interanally, and then create image by pixelBuffer.

imageCreateFromPixelArray :: Array Point Color -> IO (Image ())
imageCreateFromPixelArray pixels
   = let (Point x y) = snd (bounds pixels)
     in imageCreateFromPixels (sz (x+1) (y+1)) (elems pixels)

imageCreateFromPixels :: Size -> [Color] -> IO (Image ())
imageCreateFromPixels size colors
   = do pb <- pixelBufferCreate size
        pixelBufferSetPixels pb colors
        imageCreateFromPixelBuffer pb   -- image deletes pixel buffer

So I think we can use this function as a safe one.

Best Regards,

shelarcy <shelarcy>