Skip to content

Conversation

@bolt12
Copy link
Collaborator

@bolt12 bolt12 commented Nov 18, 2025

This PR closes #827.

@bolt12 bolt12 self-assigned this Nov 18, 2025
Comment on lines +256 to +261
> [!NOTE]
> The `hs-bindgen-runtime` library provides Template Haskell utilities for
> generating these instances manually when needed. See
> `HsBindgen.Runtime.TH.Instances` for details. This can be useful when
> working with function pointer types that `hs-bindgen` doesn't automatically
> generate instances for, or when writing custom high-level bindings.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Comment on lines +266 to +271
- Types appearing as function parameters receive `"wrapper"` imports (you need
to create function pointers to pass as arguments)
- Types for function pointer values receive `"dynamic"` imports (you
need to call returned function pointers)
- Types appearing in struct or union fields receive both (they may flow in
either direction)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrase this, and mention that these instances are only generated if the function signature has at least one domain specific type (because otherwise they would be orphans and to avoid repeating the instances)

Comment on lines +292 to +295
do
funPtr <- toFunPtr myCallback
onProgressChanged (ProgressUpdate funPtr)
freeHaskellFunPtr (un_ProgressUpdate funPtr)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this example to use bracket

Comment on lines +326 to +327
Since these function pointer types appear in struct fields, they receive both
wrapper and dynamic imports. This allows you to populate the struct with
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite right. Maybe say something like "Here we need both instances"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Introduction
  2. Safe vs Unsafe
  3. Function addresses
    3.1. current "Function pointers" beceomes section 3
    3.2. "Implicit function to pointer conversion" becomes 3.2
  4. Conversion between Haskell functions and C functions
  5. Userland CAPI: Introduction (we generate a C wrapper, yadayayada)
    5.1 Structs by value
    5.2 Static inline functions

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.

Finish support for function pointers and write tests

2 participants