
On Fri, Mar 9, 2012 at 12:48 PM, Clark Gaebel
static const double globalArray[] = { huge list of doubles }; double* getGlobalArray() { return globalArray; } int getGlobalArraySize() { return sizeof(globalArray)/sizeof(globalArray[0]); }
And importing it in haskell witht he FFI, followed with an unsafeCast:
foreign import ccall unsafe "getGlobalArray" c_globalArray :: Ptr CDouble foreign import ccall unsafe "getGlobalArraySize" c_globalArraySize :: CInt
You can use Data.Array.Storable to do this. http://hackage.haskell.org/packages/archive/array/0.3.0.3/doc/html/Data-Arra... Also, there is no need to create stub C functions, you can foreign import the array directly And if you don't want to cast between CDouble and Double you can declare your array to be of HsDouble and #include "HsFFI.h" const HsDouble globalArray[] = { huge list of doubles }; foreign import ccall unsafe "&globalArray" :: Ptr Double John