Skip to content

🦥🤝🦀 Write inline Rust snippets in Haskell.

License

Notifications You must be signed in to change notification settings

ners/inline-rust

Repository files navigation

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 directory.

-- 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.

About

🦥🤝🦀 Write inline Rust snippets in Haskell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published