Sum types, pattern matching, and Option types that Go is missing — compiled to native Go binaries
Try in Playground View on GitHubGALA (Go Alternative LAnguage) is a modern programming language that transpiles to Go. The 2024 Go Developer Survey confirmed that sum types and enums are the #1 most-requested missing feature in Go. As of Go 1.25, they still don’t exist. GALA delivers them today — along with exhaustive pattern matching, Option[T]/Either[A,B]/Try[T] monads, and immutable collections — all compiling to a single native binary through the standard Go toolchain.
Unlike libraries like samber/lo or IBM/fp-go that bolt functional patterns onto Go’s syntax, GALA adds these features at the language level with clean, concise syntax. Every Go library works out of the box. Your existing Go modules, third-party packages, and tooling remain fully compatible. GALA extends Go with the type-safety features it deliberately omits, while preserving Go’s performance, deployment simplicity, and ecosystem.
GALA’s transpiler performs type inference, exhaustive match checking, and immutability enforcement at compile time. The generated Go code is clean and readable — you can always inspect what GALA produces. There is no runtime overhead beyond what the equivalent hand-written Go would have.
Define closed type hierarchies. The compiler rejects incomplete matches — no forgotten cases at runtime.
sealed type Shape {
case Circle(Radius float64)
case Rectangle(Width float64, Height float64)
}
Exhaustive pattern matching with destructuring, guards, and expression results — far beyond Go's switch.
val msg = shape match {
case Circle(r) => f"r=$r%.1f"
case Rectangle(w, h) => f"${w * h}%.2f"
}
val bindings are immutable. Struct fields are immutable. Auto-generated Copy() for safe updates.
struct Config(Host string, Port int)
val updated = config.Copy(Port = 8080)
Option[T], Either[A,B], and Try[T] replace nil checks and if err != nil with composable pipelines.
val result = divide(10, 2)
.Map((x) => x * 2)
.FlatMap((x) => divide(x, 3))
.Recover((e) => 0)
Immutable List, Array, HashMap, HashSet, TreeSet, TreeMap with Map, Filter, FoldLeft, Collect, and more.
val nums = ArrayOf(1, 2, 3, 4, 5)
val evens = nums.Filter((x) => x % 2 == 0)
val sum = nums.FoldLeft(0, (acc, x) => acc + x)
Use any Go library. Go imports, Go types, and Go functions work directly in GALA code. One ecosystem, zero friction.
import "strings"
val name = user.Name
.Map((n) => strings.ToUpper(n))
.GetOrElse("ANONYMOUS")
Pattern matching is one of the most visible differences between GALA and Go. Where Go requires a manual type switch with field accessors, GALA destructures values directly and ensures every case is handled at compile time.
GALA
val msg = shape match {
case Circle(r) => f"r=$r%.1f"
case Rectangle(w, h) => f"$w%.0fx$h%.0f"
case Point() => "point"
}
Go
var msg string
switch shape._variant {
case Shape_Circle:
msg = fmt.Sprintf("r=%.1f",
shape.Radius.Get())
case Shape_Rectangle:
msg = fmt.Sprintf("%fx%f",
shape.Width.Get(),
shape.Height.Get())
case Shape_Point:
msg = "point"
}
GALA’s version is shorter, handles destructuring automatically, and produces a compile-time error if you forget a case. See the full GALA vs Go comparison for more examples including Option handling, immutable structs, and error handling.
Download a pre-built binary from Releases for Linux, macOS, or Windows. Or build from source:
git clone https://github.com/martianoff/gala.git && cd gala
bazel build //cmd/gala:gala
Create main.gala:
package main
struct Person(Name string, Age int)
func greet(p Person) string = p match {
case Person(name, age) if age < 18 => s"Hey, $name!"
case Person(name, _) => s"Hello, $name"
}
func main() {
Println(greet(Person("Alice", 25)))
}
gala run main.gala
Or with Bazel for larger projects:
bazel run //myapp:myapp
See the full Getting Started guide for project setup, Bazel integration, and dependency management.
GALA ships with a standard library of type-safe data structures and monads, all built on sealed types and functional programming patterns.
| Type | Description | Documentation |
|---|---|---|
Option[T] |
Optional values — Some(value) / None() |
Monadic types |
Either[A, B] |
Disjoint union — Left(a) / Right(b) |
Monadic types |
Try[T] |
Failable computation — Success(value) / Failure(err) |
Monadic types |
Future[T] |
Async computation with Map, FlatMap, Zip, Await |
Concurrency |
Tuple[A, B] |
Pairs and triples with (a, b) syntax |
Language spec |
ConstPtr[T] |
Read-only pointer with compile-time enforcement | Immutability |
| Type | Kind | Key Operations | Best for |
|---|---|---|---|
List[T] |
Immutable | O(1) prepend, O(n) index | Recursive processing |
Array[T] |
Immutable | O(1) random access | General-purpose sequences |
HashMap[K,V] |
Immutable | O(1) lookup | Key-value storage |
HashSet[T] |
Immutable | O(1) membership | Unique element collections |
TreeSet[T] |
Immutable | O(log n) sorted ops | Ordered unique elements |
TreeMap[K,V] |
Immutable | O(log n) sorted ops | Sorted key-value storage |
All collections support Map, Filter, FoldLeft, ForEach, Exists, Find, Collect, MkString, Sorted, and more. Mutable variants are available in collection_mutable for performance-sensitive code. See the collections documentation for details.
| Document | Description |
|---|---|
| Language Specification | Complete reference for GALA syntax and semantics |
| Getting Started | Installation, project setup, and first program |
| GALA vs Go | Side-by-side comparison with idiomatic Go |
| Sealed Types | Algebraic data types and closed hierarchies |
| Pattern Matching | Exhaustive matching, destructuring, and guards |
| Immutability | val, immutable structs, Copy(), and ConstPtr[T] |
| Error Handling | Option[T], Either[A,B], Try[T] monads |
| Collections | Immutable and mutable functional collections |
| Concurrency | Future[T], Promise[T], and ExecutionContext |
| Go Interop | Using Go libraries and types from GALA |
| Playground | Try GALA in your browser — no install needed |
| Project | Description |
|---|---|
| GALA Playground | Web-based playground — try it live |
| State Machine Example | State machines with sealed types and pattern matching |
| Log Analyzer | Structured log parsing with Go stdlib interop and functional pipelines |
| GALA Server | Immutable HTTP server library with builder-pattern configuration |