| 1 | <h2>Comments</h2> |
| 2 | <pre><code>-- Single line comment |
| 3 | {- Multi-line |
| 4 | comment -}</code></pre> |
| 5 | |
| 6 | <h2>Strings and characters</h2> |
| 7 | <pre><code>'a' |
| 8 | '\n' |
| 9 | '\^A' |
| 10 | '\^]' |
| 11 | '\NUL' |
| 12 | '\23' |
| 13 | '\o75' |
| 14 | '\xFE'</code></pre> |
| 15 | |
| 16 | <h2>Numbers</h2> |
| 17 | <pre><code>42 |
| 18 | 123.456 |
| 19 | 123.456e-789 |
| 20 | 1e+3 |
| 21 | 0o74 |
| 22 | 0XAF</code></pre> |
| 23 | |
| 24 | <h2>Larger example</h2> |
| 25 | <pre><code>module Main |
| 26 | |
| 27 | import Data.Vect |
| 28 | |
| 29 | -- this is comment |
| 30 | record Person where |
| 31 | constructor MkPerson2 |
| 32 | age : Integer |
| 33 | name : String |
| 34 | |
| 35 | ||| identity function |
| 36 | id : a -> a |
| 37 | id x = x |
| 38 | |
| 39 | {- |
| 40 | Bool type can be defined in |
| 41 | userland |
| 42 | -} |
| 43 | data Bool = True | False |
| 44 | |
| 45 | implementation Show Bool where |
| 46 | show True = "True" |
| 47 | show False = "False" |
| 48 | |
| 49 | not : Bool -> Bool |
| 50 | not b = case b of |
| 51 | True => False |
| 52 | False => True |
| 53 | |
| 54 | vect3 : Vect 3 Int |
| 55 | vect3 = with Vect (1 :: 2 :: 3 :: Nil) |
| 56 | </code></pre> |