Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Gala – Sealed types, pattern matching, and monads for Go (github.com/martianoff)
3 points by mmcodes 12 hours ago | hide | past | favorite | 3 comments
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.

 help



Gala looks interesting. The sealed types approach in Go reminds me of how Rust handles enums for exhaustive matching. One practical tip when using this with AI coding agents: have them generate the type hierarchies first, then pattern match logic separately. Agents tend to hallucinate less when the type contracts are explicit upfront. The monad abstractions here could also make agent-generated error handling chains much more predictable and testable.

This is exactly right. I am also very impressed how AI can pick up an unknown language and start coding in it.

The language pickup thing is genuinely fascinating. I think it works so well because AI models reason about patterns and constraints rather than memorizing syntax. A well-designed type system with clear semantics almost teaches itself. Gala's sealed types are explicit enough that an agent can infer the exhaustiveness requirements pretty naturally, even without prior training on it specifically.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: