Mastodon Feed: Post

Mastodon Feed

andreu@andreubotella.com ("Andreu Botella :verified_enby:") wrote:

I'm pumped about the enum JS proposal, (that makes enums part of core JS, not just TS) -- not so much because of the proposal itself, but because one of the possible future directions for it would finally let JS evolve to crab. 🦀

A slide, titled "Algebraic Data Type Enums": - Algebraic Data Type (ADT) enums are structured objects with some form of discriminant property. - ADT enums would tie in nicely with Extractors and Pattern Matching A code sample follows: enum Option {   Some(value),   None() } enum Result {   Ok(value),   Error(reason) } match (opt) {   Option.Some(let value): console.log(value);   Option.None(): console.log("<!-- raw HTML omitted -->"); }