Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/ners/inline-rust
- Owner: ners
- License: other
- Created: 2024-11-04T20:46:06.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-11-16T00:29:07.000Z (2 months ago)
- Last Synced: 2024-11-16T01:18:02.253Z (2 months ago)
- Topics: ffi, haskell, rust
- Language: Haskell
- Homepage:
- Size: 145 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.IntextendContext 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`.