Skip to content

Syntax sugar for record with same type name #2870

@fuzzko

Description

@fuzzko

Sometimes writing a record with same name for the type is unconvenient, especially if it's repetitive. For example

pub type User {
  User(id: Int, verified: Bool)
}

pub type Pool {
  Pool(name: String, votes: List(User))
}

pub type Message {
  Message(id: Int, owner: User, pools: List(Pool))
}

Instead of writing repetitive type A { A(B) }, we can just have type A(B).

pub type User(id: Int, verified: Bool)
pub type Pool(name: String, votes: List(User))
pub type Message(id: Int, owner: User, pools: List(Pool))

There's might be a better form for this syntax, since it's ambiguous for generic syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions