Skip to content

Instantly share code, notes, and snippets.

@shrynx
Last active March 14, 2026 06:59
Show Gist options
  • Select an option

  • Save shrynx/6e0c4059a94ed1843bfe093c68518718 to your computer and use it in GitHub Desktop.

Select an option

Save shrynx/6e0c4059a94ed1843bfe093c68518718 to your computer and use it in GitHub Desktop.
Proposal for 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))",
}
let isAdult: {user: User} -> Bool = {user} -> user.age >= 18
let domain: {user: User} -> String = {user} ->
let parts = string::split {s = user.email, sep = "@"}
seq::last {xs = parts}
let formatUser: {data: String} -> String = {data} -> do
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 adult = isAdult {user = user}
let status = if adult then "adult" else "minor"
let display = Show.show {value = user}
"Found: $(display) ($(status))"
let main = perform Console in do
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))",
}
impl User where {
isAdult = {} -> it.age >= 18,
domain = {} -> it.email.split {sep = "@"}.last {},
}
let formatUser: {data: String} -> String = {data} -> do
let user = data
.trim {}
.toLower {}
.parseJson {}
.toUser {}
let status = if user.isAdult {} then "adult" else "minor"
"Found: $(user.show{}) ($(status))"
let main = perform Console in do
let result = formatUser {data = " {\"name\": \"Alice\", \"age\": 30} "}
println {msg = result}

Discoverability

Old New
Must know string:: or Show. exists Type user. and IDE shows all methods
Helper functions scattered in modules Methods grouped with type via impl
Search docs or grep codebase Global index provides autocomplete

Inlay Hints

New style enables IDE to show types at each step:

  data.trim {}        : String
      .toLower {}     : String
      .parseJson {}   : Json
      .toUser {}      : User
      .isAdult {}     : Bool

Still Pure Functional

Property Status
Immutable data ✓ No mutation
First-class functions ✓ Pass methods as values
Currying user.greet {} vs user.greet {name = "Hi"}
Explicit effects ✓ Effects in type signatures
Method syntax ✓ Just sugar for function calls

Explcit Calling Abilty

If method conflicting issue then explcit callign ability still works

Show.for {it = user}.show {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment