notes

Personal notes
git clone git://git.laack.co/notes.git
Log | Files | Refs

Variants.md (315B)


      1 # Variants
      2 
      3 **Source:** CS3110 Efficient OCaml
      4 
      5 **Chapter:** 3.2
      6 
      7 **Definition:** Variants are OCaml's analog to enums, allowing the definition of a type with several possible values.
      8 
      9 ```ocaml
     10 type day = Sun | Mon | Tue | Wed | Thu | Fri | Sat
     11 let d = Tue
     12 ```
     13 
     14 Each element of the variant is called a constructor.