Haskell/Rust FFI

I have been using packages written by Edsko de Vries (of Well-Typed):

They make it relatively easy to serialize Rust data and pass it to
Haskell and then from Haskell back to Rust. They also provide useful handling of Rust Result.

These packages have not been touched since they were first made available a year ago.

QUESTIONS
1: Is anyone else using these packages?
2. Are there any other packages with similar capabilities?

4 Likes

I think a few may have been mentioned here:

Thanks. But I know (and have responded previously to) that thread. It does not cover what I am talking about.

As there’s been no announcement of the deprecation of those packages here:

https://well-typed.com/blog/tags/all/

I suggest contacting their author:

https://well-typed.com/people/edsko/

regarding their ongoing status.

1 Like

I’m using these for a project and I also have wondered that because I realized that one of the dependencies is pinned to GHC 9.4, so if we need to move into 9.6, and update may be required.

We’d probably submit a PR for it if it’s something we can handle.

I did find that the author was very responsive to a question I placed as an issue.

1 Like

For point n°2 I know of @yvan-sraka’s cargo-cabal

Thanks. I am aware of cargo-cabal. It is for generating the scaffolding around the project. haskell-foreign-rust and haskell-rust-ffi are for serialization of Rust data.

Apologies. Will you be interested in hs-bindgen then?

Hmm. Maybe. On a quick skim of the “overly engineered” example, it is not clear to me if the PhantomData is needed in general or just for the example — I think it is just for the example, but not sure. I’ll try it. Thanks.

Yes! You’re right @haroldcarr the example and the README of hs-bindgen is a bit overengineered, its purpose was to demonstrate that hs-bindgen could better understand Rust semantics (module system and namespacing) than e.g. Mozilla’s cbindgen https://github.com/mozilla/cbindgen/blob/master/docs.md#writing-your-c-api.

I removed the example from the README and integrated the example suggested by How do I send / recieve Rust structs in Haskell? · Issue #10 · yvan-sraka/hs-bindgen · GitHub that use borsh (like Well-Typed article). @Kleidukos also motivated me to start working on a higher-level binding generation project that would generate the borsh boilerplate code :slight_smile:

2 Likes