I managed to solve this issue.
You need to edit the myModule_stub.h file (it is automatically generated). In my case I had to change the line:
extern HsPtr myFunction_hs(HsPtr a1);
to:
extern char* myFunction_hs(const char* a1);
Of course, you should rename your myModule_stub.h
into myModule.h
after manual editing. Otherwise it will be overwritten by GHC, and your specific types will be lost.