Types and Patterns
Donna has the usual everyday types:
IntFloatStringBoolNilList(a)
Custom types use constructors.
pub type Status:
Draft
Published
Use case to branch on values.
fn status_label(status: Status) -> String:
case status:
Draft -> "draft"
Published -> "published"
Constructors can carry values.
pub type Page:
Home
Article(title: String, slug: String)
Pattern matching lets each branch name the values it needs.
fn page_title(page: Page) -> String:
case page:
Home -> "Home"
Article(title, _) -> title
Use custom types when the shape matters. A named type is often clearer than a clever tuple. Donna is practical, not cryptic.