Add Rust infrastracture in Haskell echosystem

Description

For Python, there is a library called pyo3 which can develop Python packages with Rust language.

Haskell has very similar typing system with Rust. And for system programming, Haskell with Monad is not so efficient as Rust. And when a Haskell package has dependency on C library, This Haskell package is difficult to maintain.

Rust is a memory-safe language, compared with C language.

So I would recommend that let Haskell do what it best and leave all the other system interaction, imperative stuff to Rust.

In <hackage.haskell.org> there are many Haskell packages which is inactive and broken but is necessary as dependency.

Measure

The following support of Rust in Haskell toolchain is necessary:

  • support from ghc: Add support in ghc to invoke Haskell zero-overhead and well typing support.
  • support from stack or cabal: support a Haskell package with some of its sub-module written in Rust with Cargo.toml. Or support a Haskell package which is entirely written in Rust.

Benefit

  • Compared with Haskell, Rust has a larger and more robust ecosystem.
  • When for system programming, Haskell’s monad is difficult to understand and inefficient in execution. Rust is best for doing system programming.
  • Reproducible build: Haskell cannot ensure reproducible build when it has C library dependencies. But if these dependencies are written in Rust, or Rust-bindings of C library, It can easily ensure reproductive build.

now I remember where I saw it:

1 Like

And more recently: Haskell Rust inter-operability

1 Like

I think this depends greatly on the C library in question. I maintain and use some C gamedev bindings and the pain has been pretty minimal. The single header libraries are obviously trivial. But I also use Nix for the more complicated stuff and using niche-ish C libraries from source has treated me well.

2 Likes

Unfortunately, Rust does not have an ABI and even worse it does not have an ABI for its algebraic data types.

1 Like

That seems one thing rust has in common with GHC :grin:

4 Likes

You might like this: GitHub - yvan-sraka/cargo-cabal: A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!

2 Likes

I do not see sufficient motivation for this. You say ‘monads are difficult’, but what if the current users of haskell do not find them to be so? Onboarding aside, I do not think there is an issue using haskell.

I have found this useful: Calling Purgatory from Heaven: Binding to Rust in Haskell - Well-Typed: The Haskell Consultants

3 Likes