| 1 | <h2>Comments</h2> |
| 2 | <pre><code>/* This is a comment */</code></pre> |
| 3 | |
| 4 | <h2>Strings and characters</h2> |
| 5 | <pre><code>"This is a \"string\"" |
| 6 | 'a' |
| 7 | '\\' |
| 8 | '\o123' |
| 9 | '\x4a'</code></pre> |
| 10 | |
| 11 | <h2>Constructors</h2> |
| 12 | <pre><code>type response = |
| 13 | | Yes |
| 14 | | No |
| 15 | | PrettyMuch;</code></pre> |
| 16 | |
| 17 | <h2>Example</h2> |
| 18 | <pre><code>type car = {maker: string, model: string}; |
| 19 | type carList = |
| 20 | | List car carList |
| 21 | | NoMore; |
| 22 | |
| 23 | let chevy = {maker: "Chevy", model: "Suburban"}; |
| 24 | let toyota = {maker: "Toyota", model: "Tacoma"}; |
| 25 | let myCarList = List chevy (List toyota NoMore); |
| 26 | |
| 27 | let hasExactlyTwoCars = fun lst => |
| 28 | switch lst { |
| 29 | | NoMore => false /* 0 */ |
| 30 | | List p NoMore => false /* 1 */ |
| 31 | | List p (List p2 NoMore) => true /* 2 */ |
| 32 | | List p (List p2 (List p3 theRest)) => false /* 3+ */ |
| 33 | }; |
| 34 | |
| 35 | let justTwo = hasExactlyTwoCars myCarList; /* true! */</code></pre> |