On this page:
enum
8.12

6.49 Enumerations🔗ℹ

definition

enum id_name:

  enum_clause

  ...

 

enum_clause

 = 

id ...

 | 

~is_a: annot; ...

 | 

~is_a annot

Defines id_name as a predicate annotation and as a namespace, where the namespace exports each id as the symbol #'id and as a binding form that matches the symbol #'id. The annotation is satisfied by each symbol #'id and by values satisfying any of the annots specified with ~is_a.

enum Mouse:

  itchy

  mickey minnie

  jerry

> Mouse.itchy

#'itchy

> #'itchy is_a Mouse

#true

> #'scratchy is_a Mouse

#false

> match #'jerry

  | Mouse.itchy: "scratchy"

  | Mouse.jerry: "tom"

"tom"

enum Cat:

  ~is_a String

  scratchy

  tom

> Cat.tom is_a Cat

#true

> "Felix" is_a Cat

#true