I am writing bindings (for the first time). At level C there is a function of allocating some resource, let him name it ParentRes
. He returns IO (Ptr ParentRes)
. It is created every time ParentRes
, a child resource is allocated, name it ChildRes
. This material is static, the child pointer cannot change and is freed when the parent resource is freed.
Now catch: there is a function that takes a pointer to a parent and returns a pointer to a child:
foreign import ccall unsafe "…"
c_get_child_res :: Ptr ParentRes -> IO (Ptr ChildRes)
I want to write a type wrapper Ptr ParentRes -> Ptr ChildRes
using unsafePerformIO
. Is there a reason I should not do this?
source
share