Fuse Programming Language: Statically Typed Functional Programming with GRIN
Fuse is a statically typed, purely functional programming language designed for high-performance native code generation. By compiling to the GRIN whole-program optimizer and subsequently to LLVM, Fuse provides a path from high-level functional abstractions to efficient, small native binaries with zero-cost abstractions.
Core Language Features
Fuse combines elements of System F with higher-order polymorphism to provide a robust type system. The language is designed to be expressive and composable, drawing syntax inspiration from Rust, Python, Scala, and Haskell.
Type System and Polymorphism
Fuse implements a statically typed system based on System F with higher-order polymorphism. Key components include:
- Higher-Kinded Types (HKTs): Support for HKTs allows for the creation of advanced abstractions like Functors, where a type constructor can be mapped over.
- Ad-hoc Polymorphism: Achieved through traits, which allow developers to define shared behavior across different types.
- Ad-hoc Polymorphism via Traits: Developers can use
implblocks to provide specific implementations of a trait for a type. - Algebraic Data Types (ADTs): Fuse supports ADTs and generics, enabling precise domain modeling.
Functional Paradigm
Fuse is a purely functional language where every function is a pure function. To maintain this purity while allowing for practical application, the language provides:
- Pattern Matching: Essential for working with ADTs.
- Higher-Order Functions: Functions that can take other functions as arguments or take return other functions.
- do notation: Support for
donotation allows for more readable sequencing of monadic operations. - Bidirectional Type Checking: The compiler uses bidirectional type checking with support for higher-order types. This ensures that only function type signatures are required for readability, while all other types are inferred.
Compilation Pipeline
Fuse does not compile directly to machine code. Instead, it uses a multi-stage pipeline to optimize the entire program before final code generation.
The GRIN Optimizer
Fuse compiles to GRIN, a whole-program optimizer. This architecture allows the language to perform extensive optimizations across the entire codebase, ensuring that high-level functional abstractions do not incur a runtime performance penalty.
LLVM Backend
Following the GRIN optimization phase, the code is generated via LLVM, which produces the final native binaries for Linux (x86_64) and macOS (ARM64).
Community Analysis and Technical Critiques
Community members on Hacker News have raised several technical questions and suggestions regarding the current state of the language:
Syntax and Ergonomics
Some users found the syntax—specifically the use of square brackets [] for type variables instead of the traditional angle brackets <>—to be unintuitive. There are also discussions regarding the syntax for Higher-Kinded Types in their $\eta$-long form.
Purity and IO
One reviewer noted a potential contradiction in the language's claim of purity. They observed that the existence of an .exec() method suggests that any function can perform IO actions regardless of its type signature, which may undermine the language's strict functional purity.
Standard Library and Tooling
- Editor Support: A
tree-sitter-fusegrammar has been created, indicating early progress toward Language Server Protocol (LSP) support. - Unicode Support: The standard library's string type is currently not Unicode-aware, which may impact future library design.
- User-Defined Operators: The language currently lacks user-defined operators, which some developers argue is a major obstacle to creating embedded domain-specific languages (EDSLs).
"The string type in the standard library isn't Unicode-aware... Unicode support can be a big undertaking, but considering whether you'll add it later or not might affect your library design now."
Installation
Fuse can be installed via a curl script for supported platforms (Linux x86_64 and macOS ARM64):
curl -fsSL https://fuselang.github.io/fuse/fuseup | sh