Back to browse
GitHub Repository

Scala on Go. Sealed types, pattern matching, Option/Either/Try/Future, and immutable collections — transpiled to plain Go with full third-party interop, zero-reflection JSON, and a GoLand plugin.

15 starsGo

Gala – Sealed types, pattern matching, and monads for Go

by mmcodes·Mar 1, 2026·3 points·1 comment

AI Analysis

●●●BangerBig BrainZero to One

Sealed types + exhaustive pattern matching compile to flat Go interop—no runtime overhead.

Strengths
  • Exhaustive pattern matching at compile time catches missing cases Go silently ignores
  • Output is readable, debuggable Go—not bytecode or hidden abstractions
  • Full Go standard library interop means real adoption path for existing projects
Weaknesses
  • Early-stage: no IDE tooling, no debugger integration, adoption risk on small user base
  • Learning curve for Go devs unfamiliar with functional concepts like monads
Target Audience

Go developers frustrated with boilerplate and type safety

Similar To

Scala · Kotlin · Haskell-to-C compilers

Post Description

Hi HN, I'm the author. GALA started from a simple frustration: I love Go's ecosystem, tooling, and performance, but I kept writing the same boilerplate — type switches that miss cases silently, nil checks everywhere, manual struct copy functions.

GALA is a language that transpiles to Go source code. You get sealed types (algebraic data types), exhaustive pattern matching, Option/Either/Try/Future monads, immutable-by-default values, and functional collections — and the output is readable Go that links against any Go library.

A quick taste:

sealed type Shape { case Circle(Radius float64) case Rectangle(Width float64, Height float64) }

func area(s Shape) string = s match { case Circle(r) => fmt.Sprintf("circle area: %.2f", 3.14 * r * r) case Rectangle(w, h) => fmt.Sprintf("rect area: %.2f", w * h) }

This compiles to a flat Go struct with a variant tag. The compiler enforces exhaustiveness — add a Triangle case and forget to handle it, you get a compile error, not a runtime bug.

The standard library is written in GALA itself: Option[T], Either[A,B], Try[T], Future[T], plus immutable List, Array, HashMap, HashSet, TreeSet, TreeMap — all with Map, Filter, FoldLeft, Collect, etc.

How I actually develop in GALA — no IDE needed:

The biggest honest gap right now is traditional IDE support. There's an IntelliJ plugin for syntax highlighting, but no LSP, no autocomplete, no go-to-definition. Here's the thing though: I built the entire language and standard library using Claude Code as my development environment. Claude knows the GALA grammar, the type system, and the standard library — it writes GALA fluently, catches transpiler errors, and suggests idiomatic patterns. For me it's been a more productive workflow than any IDE could offer for a young language. If you're already using AI-assisted development, GALA works great today. If you need traditional IDE tooling to be productive, that's a real limitation I want to be upfront about.

Some other honest notes: - This is pre-1.0. The language works (107 verified examples, CI on every commit), but I'm sure there are edge cases I haven't hit. - The transpiler is a single-developer project. It handles multi-file packages, generics, type inference, and full Go interop, but it's early. - The compiler — type inference, sealed type code generation, exhaustiveness checking — was built collaboratively with Claude as a pair programmer. Happy to answer questions about that workflow.

Technical details for the compiler nerds: GALA source → ANTLR4 parse tree → GALA AST → Go AST → Go source. Type inference resolves lambda parameter types, generic type arguments, and method return types without annotations in most cases.

Repo: https://github.com/martianoff/gala

I'm curious what people think about the sealed-type-to-flat-struct compilation approach and the tradeoffs of transpiling vs. extending Go directly.

Similar Projects