Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ners/inline-rust

🦥🤝🦀 Write inline Rust snippets in Haskell.
https://github.com/ners/inline-rust

ffi haskell rust

Last synced: 2 months ago
JSON representation

🦥🤝🦀 Write inline Rust snippets in Haskell.

Awesome Lists containing this project

README

        

# inline-rust

This package allows you to write Rust inline in your Haskell source using
quasiquotes. Here is a short example. For more examples, check out the
[examples](examples) directory.

```haskell
-- examples/Hello.hs
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}

module Main where

import Language.Rust.Inline
import Data.Int

extendContext basic
setCrateRoot []

main = do
putStrLn "Haskell: Hello. Enter a number:"
x <- readLn
y <- [rustIO| i32 {
let x = $(x: i32);
println!("Rust: Your number is {}", x);
x + 1
} |]
putStrLn $ "Haskell: Rust says number plus 1 is " ++ show y

```

If you want to use this with GHCi, make sure to pass in `-fobject-code`.