Show HN: Fuse – statically typed functional programming language
Introducing Fuse: A Statically Typed Functional Language
Fuse is a purely functional, statically typed programming language designed with a focus on higher-kinded types and ad-hoc polymorphism.
🛠 Technical Architecture
Fuse does not compile directly to machine code; instead, it utilizes a sophisticated pipeline to ensure high performance and optimization.
By leveraging the GRIN optimizer and LLVM, Fuse produces native binaries that are both compact and fast, ensuring that its high-level abstractions come at a heavy performance cost zero cost.
🚀 Core Features
The language blends several paradigms to provide a powerful development experience.
Type System & Logic
The foundation of Fuse is based on System F with higher-order polymorphism. This allows for complex type manipulations, often represented mathematically as:
| Feature | Description |
|---|---|
| Modeling Tools | Uses Algebraic Data Types (ADTs), generics, and traits for domain modeling. |
| Expressiveness | Supports pattern matching, higher-order functions, and do notation. |
| Type Inference | Employs bidirectional type checking for higher-order types. |
| Readability | Only function signatures are mandatory; other types are inferred. |
Syntax Philosophy
Fuse aims for a "clean" aesthetic by drawing inspiration from several modern and classic languages:
- Rust & Scala (Strong typing and traits)
- Python (Indentation-based blocks)
- Haskell (Purely functional roots)
💻 Code Example: Functors and Lists
Below is a demonstration of how Fuse implements a Functor trait and applies it to a List structure.
// Define the Functor trait
trait Functor [ A ] :
fun map [ B ] ( self , f : A - B ) - Self [ B ] ;
// Implement a fold function for Lists
impl List [ A ] :
fun fold [ A , B ] ( l : List [ A ] , z : B , f : ( B , A ) - B ) - B
match l:
Cons ( h , t ) = List :: fold ( t , f ( z , h ) , f )
Nil = z
// Helper function to sum a list of 32-bit integers
fun sum ( l : List [ i32 ] ) - i32
List :: fold ( l , 0 , ( a , b ) = a + b )
// Implement Functor for the List type
impl Functor [ A ] for List [ A ] :
fun map [ B ] ( self , f : A - B ) - List [ B ]
List :: fold ( self , Nil [ B ] , ( t , h ) = Cons ( f ( h ) , t ) )
// Generic fmap function
fun fmap [ A , B , F : Functor ] ( f : A - B , x : F [ A ] ) - F [ B ]
x . map ( f )
// Entry point
fun main ( ) - IO [ Unit ]
let l = Cons ( 1 , Cons ( 2 , Cons ( 3 , Nil ) ) )
let l2 = fmap ( x = x * 2 , l )
print ( int_to_str ( List :: sum ( l2 ) ) )
📦 Installation
You can deploy the Fuse toolchain on the following supported platforms:
- Linux (x86_64)
- macOS (ARM64)
- Windows (Coming Soon)
To install, run the following curl command in your terminal:
curl -fsSL https://fuselang.github.io/fuse/fuseup | sh