Protean-Labs / mesh

The Mesh Engine that implements the Mesh Language, a computational language for web3.
Apache License 2.0
1 stars 0 forks source link

Polymorphic Variant Types and Basic Match Statement #75

Open ThierryBleau opened 3 years ago

ThierryBleau commented 3 years ago

Syntax candidate

//type user: [ Profile({name: string, age: int}), Anon(int) , Mod];

// visitor: [Profile(_), Anon(_), Mod]
let visitor = Anon(0);

// f: [Profile(_), Anon(_), Mod ] => string
let f = (x) => switch (x) {
  | Profile(_) => "profile"
  | Anon(_) => "anon"
  | Mod => "mod"
}