Beyond Proc-Macros: A Trait-Based Framework for Bindgen
summary
Generates C-ABI FFI bindings between Rust and Haskell using a trait-based framework rather than only proc macros, implemented as hs-bindgen that is compact (under 1,000 LOC) and works in demos. Enforces FFI-safe types at compile time via a private C-FF-safe trait and From/Into-like traits, automates pointer ownership, pinning and vector conversions, and emits C glue code from proc-macro expansion. Documents proc-macro limits: token-stream API, no compile-time type reflection, slow builds, and cases where runtime mismatches still occur.
AI-written summary · about
