phie

Crates.iophie
lib.rsphie
version0.2.0
sourcesrc
created_at2022-05-06 13:50:30.618945
updated_at2022-09-19 18:37:54.48235
descriptionExperimental emulator of a processor that understands πœ‘-calculus expressions
homepagehttps://github.com/objectionary/phie
repositoryhttps://github.com/objectionary/phie
max_upload_size
id581700
size99,142
Yegor Bugayenko (yegor256)

documentation

README

logo

EO principles respected here We recommend IntelliJ IDEA

cargo crates.io PDD status Hits-of-Code Lines of code License

It's an experimental emulator of a processor that understands πœ‘-calculus expressions, which is the formalism behind EO programming language.

To build it, install Rust and then:

$ cargo build --release

If everything goes well, an executable binary will be in target/release/fibonacci:

$ target/release/fibonacci 7 40

This will calculate the 7th Fibonacci number 40 times. Don't try to play with much larger numbers, this binary code is very slow. It's just an experiment.

To compile your own program instead of this primitive recursive Fibonacci calculator, you have to convert EO code into πœ‘-calculus expressions and then pass them to Emu struct like this:

use phie::emu::Emu;
pub fn main() {
    let emu: Emu = "
        Ξ½0 ↦ ⟦ πœ‘ ↦ Ξ½3 ⟧
        Ξ½1 ↦ ⟦ Ξ” ↦ 0x002A ⟧
        Ξ½2 ↦ ⟦ Ξ» ↦ int-add, ρ ↦ πœ‹.𝛼0, 𝛼0 ↦ πœ‹.𝛼1 ⟧
        Ξ½3 ↦ ⟦ πœ‘ ↦ Ξ½2(ΞΎ), 𝛼0 ↦ Ξ½1, 𝛼1 ↦ Ξ½1 ⟧
        Ξ½5 ↦ ⟦ πœ‘ ↦ Ξ½3(ΞΎ) ⟧
    ".parse().unwrap();
    let dtz = emu.dataize();
    print!("The result is: {}", dtz.0);
}

This code is equivalent to the following EO code:

[] > foo
  42 > x
  x.add x > @

But in a more "functional" way:

[] > foo
  42 > x
  int-add > @
    x
    x

More tests are in src/emu.rs file.

Run and fix Clippy lints issues before committing changes:

  1. Install Rustup. If Rustup was already installed, update to ensure have the latest Rustup and compiler.
$ rustup update
  1. Install Clippy.
$ rustup component add clippy
  1. Run Clippy.
$ cargo clippy
  1. Automatically applying Clippy suggestions (Not all issues will be fixed automatically. Also, Clippy has some bugs with false-positive cases for some lints, so better to check automaticall fixes as well).
$ cargo clippy --fix
Commit count: 265

cargo fmt