louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#115 · main · 21 min 41 s
0Étoiles
0Forks
40Issues
| 1 | effect fail |
| 2 | { |
| 3 | final ctl fail :: reason: String -> Never |
| 4 | } |
| 5 | |
| 6 | // `Never` fits wherever a value is expected. |
| 7 | pub fn checked :: n: Int -> Int / <fail> |
| 8 | { |
| 9 | if n < 0 |
| 10 | { |
| 11 | fail "negative" |
| 12 | } |
| 13 | else |
| 14 | { |
| 15 | n |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | pub fn first :: xs: List<a> -> a / <fail> |
| 20 | { |
| 21 | match xs { [x, ..] -> x, [] -> fail "empty" } |
| 22 | } |