Skip to content

Instantly share code, notes, and snippets.

@shrynx
Last active March 13, 2026 20:33
Show Gist options
  • Select an option

  • Save shrynx/02adab363fdf860356ecfff1bb20511a to your computer and use it in GitHub Desktop.

Select an option

Save shrynx/02adab363fdf860356ecfff1bb20511a to your computer and use it in GitHub Desktop.
Porosing new syntax extension to mezze
# =============================================================================
# Mezze - Current Style
# =============================================================================
#
# - Explicit module-qualified calls
# - All parameters named
# - Many let bindings to avoid deep nesting
# - Must know module/ability names upfront
# =============================================================================
ability Show 'a where {
show: {value: 'a} -> String,
}
type User = {name: String, age: Int, email: String}
impl Show User where {
show = {value} -> "User($(value.name), $(value.age))",
}
# --- Processing: step by step with let bindings ---
let formatUser: {data: String} -> String = {data} ->
let trimmed = string::trim {s = data}
let lower = string::toLower {s = trimmed}
let parsed = json::parse {s = lower}
let user = User.fromJson {json = parsed}
let display = Show.show {value = user}
"Found: $(display)"
# --- Or deeply nested (inside-out, hard to follow) ---
let formatUserNested: {data: String} -> String = {data} ->
let user = User.fromJson {
json = json::parse {
s = string::toLower {
s = string::trim {s = data}
}
}
}
"Found: $(Show.show {value = user})"
let main = perform Console in
let result = formatUser {data = " {\"name\": \"Alice\", \"age\": 30} "}
println {msg = result}
# =============================================================================
# Mezze - New Style (Proposed)
# =============================================================================
#
# - Method chaining: data flows left-to-right, top-to-bottom
# - IDE discovery: type "value." to see available methods
# - Inlay hints show type at each step of chain
# - "it" is implicit receiver in impl blocks
# =============================================================================
ability Show for 'a where {
show: {} -> String,
}
type User = {name: String, age: Int, email: String}
impl Show for User where {
show = {} -> "User($(it.name), $(it.age))",
}
# Adding methods directly to User (anonymous impl)
impl User where {
isAdult = {} -> it.age >= 18,
domain = {} -> it.email.split {sep = "@"}.last {},
}
let formatUser: {data: String} -> String = {data} ->
data
.trim {}
.toLower {}
.parseJson {}
.toUser {}
.show {}
.prepend {s = "Found: "}
let main = perform Console in
let result = formatUser {data = " {\"name\": \"Alice\", \"age\": 30} "}
println {msg = result}
# --- Processing: method chain, reads naturally ---
#
# IDE inlay hints:
# data.trim {} : String
# .toLower {} : String
# .parseJson {} : Json
# .toUser {} : User
# .show {} : String
# .prepend {...} : String
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment