Git Product home page Git Product logo

fluorine-rs's Introduction

Logo Rust

fluorine-rs

A functional programming language with my personal preference.

Features

  • Trait-based OO
  • Generic Types
  • Pattern matching
  • Rust-like enums
  • Optional type hints
  • Operator overloading via traits
  • Easy-to-use FFI macros

Examples

  • Pattern matching
enum Expr {
    Add(Expr, Expr),
    Sub(Expr, Expr),
    Mul(Expr, Expr),
    Div(Expr, Expr),
    Lit(Number),
}

let eval = { expr ->
    match expr {
        Add(l, r) => eval(l) + eval(r),
        Sub(l, r) => eval(l) - eval(r),
        Mul(l, r) => eval(l) * eval(r),
        Div(l, r) => eval(l) / eval(r),
        Lit(n)    => n,
    }
}

// (1 + 8) * 10
let tree = Mul(Add(Lit(1), Lit(8)), Lit(10))

// 90
println(eval(tree))
  • Traits and Impl
enum Data {
    EmptyData,
}

trait Greet {
    let greeting: (self, name: String) -> Unit
}

trait Call {
    let call: (self, unit: Unit) -> Unit
}

impl Greet for Data {
    let greeting = { self, name -> println("hello " + name) }
}

impl<T: Greet> Call for T {
    let call = { self, _ -> self.greeting("fluorine") }
}

let data = EmptyData();
// hello fluorine
data.call(());
  • FFI macros
#[fluorine(Prelude)]
mod prelude_ffi {
    use crate::ffi::*;
    
    #[fluorine]
    fn hello(name: String) {
        println!("hello {}", name);
    }
}

and in fluorine, just do:

Fs> hello("jobs")
hello jobs

Acknowledge

We would like to thank JetBrains for sharing free open-source licences of amazing tools such as CLion.

fluorine-rs's People

Contributors

imkiva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.