Soppo
A language that compiles to Go, adding ergonomic and type safety features that Go lacks. Soppo uses Go syntax wherever possible - if you know Go, you know most of Soppo.
See docs/DESIGN.md for language design.
Soppo is not production ready.
Installation
The recommended way to install Soppo is through SOPMOD, an installer and version manager for Soppo.
|
You can also install Sop manually by installing Go and downloading a binary from GitHub Releases, or with Cargo: cargo install soppo.
Note: SOPMOD itself is written entirely in Soppo. Check out its source code for a real-world example.
Features
- Enums: Tagged unions with struct variants
- Pattern matching: Exhaustive matching with destructuring
- Error handling:
?propagation and? err { }custom handling - Nil safety: Compile-time nil checks
- Named arguments:
func(name: value)for clarity - String interpolation:
"value: {var}"syntax - Detailed error messages: Rust-inspired compiler diagnostics
- Go interop: Use any Go library directly
- Batteries included: LSP, formatter, test runner with doctests
Quick Look
// Enums with struct variants
type Shape enum
// calcArea returns the area of a shape.
//
// Doctests - code examples that run as tests:
// ```sop
// import "fmt"
//
// circle := Shape.Circle{radius: 2.0}
// fmt.Println(calcArea(circle))
// // Output:
// // 12.56636
// ```
func calcArea(s Shape) float64
func printArea() error
func main()
Error Messages
The compiler catches errors early with helpful messages:
× Non-exhaustive match
╭─[main.sop:11:5]
10 │ var message string
11 │ ╭─▶ match colour {
12 │ │ case Colour.Red:
13 │ │ message = "Stop"
14 │ │ case Colour.Yellow:
15 │ │ message = "Wait"
16 │ ├─▶ }
· ╰──── missing variants: Green
17 │ }
╰────
help: Ensure all enum variants are handled, or add a `default` case
License
BSD 3-Clause. See LICENSE.