ghci

A crate to manage and communicate with ghci sessions.
let mut ghci = new?;
let out = ghci.eval?;
assert_eq!;
Platform support: Unix only (Linux, macOS, BSDs).
Features
Type conversions
Convert between Rust and Haskell values with ToHaskell / FromHaskell, and evaluate expressions directly into Rust types with eval_as:
use ;
let mut ghci = new?;
let x: i32 = ghci.eval_as?;
assert_eq!;
// Built-in support for common types
assert_eq!;
assert_eq!;
assert_eq!;
Derive macros
With the derive feature, automatically derive conversions for your own types:
use ;
// Point { x: 1, y: 2 } <-> "Point {x = 1, y = 2}"
;
// Pair(1, true) <-> "(Pair 1 True)"
See the derive macro docs for all supported attributes (name, transparent, style, skip, bound).
Configuration
Use GhciBuilder to configure the ghci session:
use GhciBuilder;
let mut ghci = new
.ghci_path
.arg
.working_dir
.build?;
Timeouts
use Duration;
ghci.set_timeout;
Shared sessions
SharedGhci provides a thread-safe, lazily-initialized session for use in tests:
use ;
static GHCI: SharedGhci = new;
let mut ghci = GHCI.lock;
let out = ghci.eval.unwrap;
assert_eq!;
See the docs for the full API.
License
Copyright 2023 Basile Henry