#haskell #rts #ffi

yanked ghc-rts-rs

Link in the Haskell Runtime to run Haskell inside Rust

Uses old Rust 2015

0.0.1 Jan 25, 2018

#15 in #rts

MIT/Apache

13KB
175 lines

ghc-rts-rs

This is code used to link in the GHC RTS in statically to make it possible to run Haskell inside Rust. This is intended to be used as part of curryrs package as a dependency. However, it's functionality is being separated out as a base library that others can use on their own. You choose which version of GHC you want to use and the modified source files here will compile an optimized build with the correct version and DWARF symbols turned on.

It also provides wrappers around the hs_init and hs_exit functions so that you can easily start and stop the runtime from your code.

Beyond this functionality the library does nothing else in order to make FFI nicer to use or simplified. If you are looking for a higher level library to make Rust/Haskell FFI easier then take a look at curryrs.

Build Time

This takes an incredibly long time to build unfortunately. I would highly recommend not changing to newer versions of Rust often, meaning use stable if possible as that only changes every 6 weeks. Once compiled you shouldn't need to touch it again unless your Rust or GHC compiler changes.

Start/Stop the Runtime

extern crate ghc_rts;
use ghc_rts::{start, stop};

fn main() {
  start(); // Starts the Haskell Runtime. Can be called more than once
  stop();  // Stops the Runtime. Will panic if called more than once as the RTS
           // can't be started again now, nor stopped.
}

Dependencies

You'll need the following tools installed to be able to compile the RTS:

You might need the static versions in order to work. For instance I needed the ghc-static package on Arch Linux. Play around with it to figure it out!

Contributing

See CONTRIBUTING.md for more information.

License

Licensed under either of

at your option.

Licensing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–1MB