I am exposing a Haskell function to C/C++ as
foreign export ccall foo :: Ptr CInt -> CInt -> IO CInt
foo ptr len = do
list <- peekArray (fromIntegral len) ptr
-- run calculation based on list entries
return result
The signature of the exported function becomes
HsInt32 foo(HsPtr a1, HsInt32 a2);
However, since the array is not being modified, I would rather have this as
HsInt32 foo(const HsPtr a1, HsInt32 a2);
Is there a way to automatically add this annotation?
(The motivation is that I want this to operate on an std::vector< int > via
inline int foo(const std::vector<int> &v)
{
return foo(v.data(), v.size());
}
without including a const_cast.)