Conversation
georgefst
force-pushed
the
rust-ffi
branch
5 times, most recently
from
August 4, 2026 16:09
f933f7c to
9639e6f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the end result of my investigations in to how best to call Rust code from Haskell.
The general idea is as follows. We have a Rust crate
geomerge-ffiwhich compiles to a static library. We runcbindgenon this to generate a corresponding header file. Then the new Haskell FFI toolhs-bindgencan act as though it's dealing with a C library, and generate automatic bindings.What's neat about this approach is that:
While
hs-bindgenhas improved substantially since I first looked in to it a few months ago, it's still in alpha and there are still some rough edges. No bugs as such that I've found, but there are a lot of open questions as to best practice for using it this way. Note the TODO comments in the main (penultimate) commit.I'll likely be carrying on these experiments in some other project. For Coln, I suspect that none of the remaining contributors would want to take on the maintenance burden of actually merging this work. Especially since the actual interface between the Coln compiler and the storage engine is likely to involve infrequently passing JSON back and forth between Wasm modules, rather than there being any need for a single native binary. Nevertheless, I see no harm in leaving this here as a proof-of-concept.
In the final commit on this branch, I vibe-coded some JSON serialisation tests which make use of this FFI work, and which have discovered bugs in Coln. I'll merge those via a separate PR. It is cool to be able to test the Rust code from the Haskell test runner, but there are certainly simpler ways to test the JSON encoding consistency than making use of all this machinery.