• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Haskell
  • License
    The Unlicense
  • Created almost 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Toy example of calling Rust from Haskell

Rust-Haskell FFI Example

A lot of Haskell people I've talked to are excited about the prospect of using Rust as a replacement for C in certain speed-critical or low-level parts of their application. To that end, and in light of the recent (as of this writing) Rust 1.0 alpha release, I've shown here a small example of calling Rust from Haskell.

This contains a single Haskell file and two Rust libraries which Haskell can call out to. The first Rust library is contained in fact.rs and implements a simple factorial, which is easier to wrap; the second is contained in point.rs and demonstrates allocating memory in Rust, passing it to Haskell, using wrapped Rust functions to manipulate it, and finally allowing Haskell's GC to call back into Rust to free it.

This of course requires GHC and a reasonably recent version of rustc installed. This version has been tested with GHC versions 7.8.4 and 7.10.1, and the following rustc versions:

1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)

All the examples here I release into the public domain.

More Repositories

1

haddock-cheatsheet

103
star
2

s-cargot

Elaborate and expressive S-Expression library for Haskell
Haskell
59
star
3

config-ini

A monadic DSL for simple configuration parsing
Haskell
23
star
4

rrecutils

A pure Rust implementation of the GNU Recutils format
Rust
23
star
5

bison-flex-sample

A small bison/flex example for a trivial asm-ey language
Yacc
12
star
6

hvif

A Haiku Vector Icon Format library for Haskell
Haskell
12
star
7

apicius

Haskell
10
star
8

fruit-icons

A large number of drawings of fruit.
6
star
9

apicius-rs

Rust
6
star
10

xleb

A simple monadic language for parsing XML structures.
Haskell
6
star
11

brick-table

Haskell
5
star
12

cab

A glorified, unnecessary alias for Cabal
Rust
4
star
13

bunyan

A Changelog Generation Helper
Haskell
4
star
14

cube-cotillion

Haskell
3
star
15

activitystreams-aeson

Basic library for working with Activity Streams
Haskell
3
star
16

liblibc

Rust
3
star
17

void-extra-packages

Extra template files for Void Linux
Shell
2
star
18

dw-playbooks

TeX
2
star
19

telml

A generic, more lightweight data format for textual markup
Haskell
2
star
20

posts

Rust
2
star
21

yoctolens

The Smallest Lens Package You Can Think Of
Haskell
2
star
22

hypsibius

Haskell
2
star
23

yaml-dir

Haskell
1
star
24

rust-camkes-samples

Rust
1
star
25

aeson-ld

JSON-LD library built on top of Aeson
Haskell
1
star
26

job-runner-strawman

Haskell
1
star
27

drunken-bishop

Haskell
1
star
28

ndbl

Near-minimal config format
Haskell
1
star
29

verify

A small solution to `curl | sh`
Shell
1
star
30

charter

A tool for Haskell project scaffolding
Haskell
1
star
31

ptolemy

Haskell
1
star
32

tansu

A storage-agnostic key-value-store interface.
Haskell
1
star
33

khuzd

Very basic multi-user blog system
Haskell
1
star
34

dmesktop

a `dmenu`-based application launcher using `.desktop` files
Python
1
star
35

twote

Ruby
1
star
36

lektor

Tentative steps towards a family of feed readers
Haskell
1
star
37

sprinkles-opts

A terse Sorbet-compatible command-line option parser
Ruby
1
star
38

adnot-hs

Haskell
1
star
39

tansu-sqlite3

Berkeley DB-based backend for the Tansu key-value API
Haskell
1
star
40

smaccm-propellor

Haskell
1
star
41

simple-befunge

A small-ish Befunge interpreter in Haskell
Haskell
1
star
42

frontit

Haskell
1
star
43

ucspi-hs

UCSPI interface wrappers for Haskell
Haskell
1
star
44

capdl

Haskell
1
star
45

profile-site

A simple site for art profiles.
Haskell
1
star
46

robigalia-rust-sel4

Rust
1
star
47

electric-boogaloo

Opinionated sugar for SQLite table definitions
Haskell
1
star
48

treant

Haskell
1
star
49

rust

rust compiler fork (with stubbed-out sel4 support)
Rust
1
star
50

docker-presentation

Haskell
1
star
51

tansu-berkeleydb

Berkeley DB-based backend for the Tansu key-value API
Haskell
1
star
52

matzo

A little language for random text
Rust
1
star