Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getWindowPropertyPtr returning IO (Maybe (ForeignPtr a, Int)) #104

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mgkurtz
Copy link

@mgkurtz mgkurtz commented Apr 29, 2024

This is a draft for the concept discussed in #52. Actually, I did not even test it (beyond building). Quite likely, I have cheated when setting the type of xFreePtr to FinalizerPtr a = FunPtr (Ptr a → IO ()) instead of FunPtr (Ptr a → IO Int). I do not know, what would be a clean solution here.

As I am not very experienced with regards to Haskell building and testing, I would appreciate any help.

@geekosaur
Copy link
Contributor

I've been thinking about this, and I'm not sure it's a good idea to expose internals like that; it's usually better to pull C values into Haskell and immediately free the C side instead. The main exception would be when you want to make a ByteString from it, in which case you want https://downloads.haskell.org/ghc/9.2.5/docs/html/libraries/bytestring-0.11.3.1/Data-ByteString-Unsafe.html#v:unsafePackCStringFinalizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants