14 Commits

Author SHA1 Message Date
George Thomas
c37b013467 Revert "ditch bash script for custom setup"
This reverts commit 1399946c4d582eaabb64cece292a48159b745e64.
2026-03-19 11:35:00 +00:00
George Thomas
22b6fac5b5 ditch bash script for custom setup
eugh, but this requires
"haskell.sessionLoading": "singleComponent"
2026-03-19 11:35:00 +00:00
George Thomas
927bf229a4 move bindings generation to Rust build script
bit cleaner, esp. as less hardcoding of "debug" path

instant updates all the way through to Haskell when we change Rust code
(this wasn't actually working at all before even when we did manually run the script, because TH file-dependency tracking seemed to get confused with the way that the Bash code moved a file to the header path rather than editing it)

should update to point to my comment on hs-bindgen

actually, isn't there a race condition here? the header files are generated before the new Rust code is actually compiled, and Cabal could in theory end up still linking against the old output

hardcoding "target" isn't great, though we do already do so in the Cabal file
there seems to be no env var for it though
docs suggest we're supposed to use OUT_DIR, but that has an unpredictable path... we could output the dir somewhere I suppose, and configure Cabal to use that, but that adds a fair bit of complexity

look in to https://doc.rust-lang.org/cargo/reference/build-scripts.html#change-detection?
bit blunt compared to e.g. Cabal Hooks, and anyway I think in the long run I'll be ditching `build.rs`, as discussed above
2026-03-19 11:35:00 +00:00
George Thomas
beb9e14542 drop hooks in favour of using bundled libraries properly
script addition is hacky, but I know no other way to get most of the build path, in arch/version-independent way
we'll use a custom setup or whatever eventually (_eventually_ hooks...) anyway
2026-03-19 11:35:00 +00:00
George Thomas
ffc59a418b remove cabal configure hack for lib/include dirs 2026-03-19 11:35:00 +00:00
George Thomas
a018cc389a Generate header in Rust build output directory 2026-02-20 09:53:12 +00:00
George Thomas
96ec5c1cb1 Switch to Template Haskell mode for hs-bindgen 2026-02-20 09:08:16 +00:00
George Thomas
e977181252 Avoid typedefs
This makes the header simpler, and silences `hs-bindgen` notices about "squashed" typedefs.
2026-02-19 17:22:15 +00:00
George Thomas
9ca4f615d8 Use simpler tagged union translation
Avoids the worst part of the header hack, and makes Haskell wrapper simpler.
2026-02-19 17:22:15 +00:00
George Thomas
40bb939302 Stick to Rust debug builds in shell to avoid C lib dir confusion 2026-02-19 16:29:52 +00:00
George Thomas
ddc8b9097d Avoid absolute path hack 2026-02-19 16:29:52 +00:00
George Thomas
25875c7dc1 Move Haskell package to top level 2026-02-19 16:29:52 +00:00
George Thomas
f1ec06fcca Add Bash script dependencies to Nix shell 2026-02-19 16:29:52 +00:00
George Thomas
0a1911862f Expose explicit C interface
We drop the tools specifically designed for Haskell and Rust together, in favour of general tools for using each with C.

Namely, we use Mozilla's `cbindgen` for generating header files from the Rust source, and Well-Typed's new `hs-bindgen` tool for generating Haskell from those header files.

The Rust code here is essentially the result of expanding the old macro, then inlining and renaming internals.

The most important thing here is that we're now relying solely on robust well-maintained tools.
2026-02-19 16:29:41 +00:00