Cannot be removed IOfrom type without use unsafePerformIO. However, in this case, you can get a function with the type you want, with some caveats. In particular, the C function "foo" cannot depend on any global variables, a thread-local state, or anything other than a single argument. In addition, the call foo(bar)should always provide the same result when it bardoes not change.
I expect an attempt to import a C function
bar foo(bar input);
f_foo :: BarPtr -> BarPtr
- . , ( C):
void wrap_foo(bar *barPtr) {
bar outp = foo(*barPtr);
*barPtr = outp;
}
f_wrap_foo :: BarPtr -> IO ()
, :
fooBar :: Bar -> Bar
fooBar bar = unsafePerformIO $ with bar $ \barPtr -> do
f_wrap_foo barPtr
peek barPtr