Skip to content

enlightware/ferlium

Repository files navigation

Ferlium

Build Status

Created by Enlightware GmbH for use in Candli.

Our mission: To bring the power of Haskell to the users of Python and Javascript

Ferlium is a small functional scripting language with generics and static typing (à la Standard ML). It aims at bringing the convenience of writing of Python, the safety of Rust, and the expressiveness of Haskell. It achieves so by borrowing the type system from Haskell, the syntax from Rust, and a simple mutable value semantics from recent academic research. With that semantics, a function argument is either a value or a mutable reference to a value on the stack, and a simple borrow checker ensures memory safety. Functions always return values.

Ferlium aims at being lightweight and interfacing nicely with Rust.

Getting started

We provide a playground here.

We also provide a REPL to play locally with the language:

cargo run --example ferlium

You can read a small book about the language here.

You can reach us on Zulip: ferlium.zulipchat.com

Key features

For users

  • Functional statically-typed scripting language
  • Algebraic structural data types (including tagged unions)
  • Rust-style new types (structs and enums) over structural data types
  • Type inference (Hindley-Milner style, HM(X) flavor)
  • Parametric polymorphism (generics)
  • Ad hoc polymorphism through traits (type classes), with support for multi-parameter traits and associated types
  • Row polymorphism (for algebraic data types)
  • Optional type annotations, including _ holes for partial annotations
  • First-class and anonymous functions, including capture of outer variables by value (closures)
  • Pattern matching
  • Function pipelining with the |> operator
  • Mutable value semantics (a simplified version of Rust's ownership system)
  • Modules
  • Simple copy-on-write optimisation on arrays to maintain acceptable performance

For developers and integrators

  • A pragmatic language: e.g. provides a mutable value semantics
  • Avoid re-implementing native types in the HIR (i.e., no int, bool, etc. explicit there),
  • Smooth binding with native Rust code (currently as interpreted code, later through a simple ABI)
  • Rich integration possibilities with the native platform (e.g. for platform-managed values)

Scope and non-scope

The issues list the planned features.

The following features are out of scope:

  • Dynamic dispatch

Inspirations

Running tests

To run the tests locally, use:

make test-local

This use nextest which is way faster than cargo test.

Running benchmarks

We use Gungraun for benchmarking, which provides high-precision measurements using Valgrind.

To run the benchmarks locally, first ensure you have Valgrind and the Gungraun runner installed:

make install-deps

Then run the benchmarks:

cargo bench

Gungraun measures instruction counts and other metrics to detect small optimizations and regressions reliably, even in noisy environments.

Limitations

Currently the compiler can only be used from a single thread to avoid deadlocks when accessing the interned type universe. Currently the compiler will panic if the corresponding lock is held when being accessed in write.

Contributing

See CONTRIBUTING.md for details on how to contribute.

License and trademark

Ferlium is copyrighted by Enlightware GmbH and licensed under the Apache 2.0 license.

"Ferlium" is a trademark of Enlightware GmbH. See TRADEMARK.md for permitted uses.

The tests in tests/language/ constitute the official Ferlium Conformance Suite.

About

Our mission: To bring the power of Haskell to the users of Python and Javascript.

Resources

License

Contributing

Stars

Watchers

Forks

Contributors