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
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
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.