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#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | pub type Color { Red, Green } |
| 2 | |
| 3 | impl Show<Color> |
| 4 | { |
| 5 | fn show :: c |
| 6 | { |
| 7 | match c { Red -> "red", Green -> "green" } |
| 8 | } |
| 9 | } |
| 10 | |
| 11 | pub fn shown :: -> String |
| 12 | { |
| 13 | show Red |
| 14 | } |
| 15 | |
| 16 | pub type Point { Point(x: Int, y: Int) } |
| 17 | |
| 18 | impl Eq<Point> |
| 19 | { |
| 20 | fn eq :: a b |
| 21 | { |
| 22 | a.x == b.x && a.y == b.y |
| 23 | } |
| 24 | fn extra :: //~ ERROR E0406 not a method of trait `Eq` |
| 25 | a |
| 26 | { |
| 27 | a |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl Show<Point> //~ ERROR E0407 missing method `show` |
| 32 | {} |
| 33 | |
| 34 | impl Show<Color> {} //~ ERROR E0404 implemented more than once |
| 35 | |
| 36 | pub fn no_impl :: -> Bool |
| 37 | { |
| 38 | (fn x { x }) == (fn x { x }) //~ ERROR E0401 does not implement `Eq` |
| 39 | } |
| 40 | |
| 41 | pub fn nested_no_impl :: f: fn() -> Int -> String |
| 42 | { |
| 43 | show |
| 44 | //~^ ERROR E0401 `fn() -> Int` does not implement `Show` (needed for `Show<List<fn() -> Int>>`) |
| 45 | [f] |
| 46 | } |
| 47 | |
| 48 | @derive Eq Show |
| 49 | pub type Pair<a> { Pair(a, a) } |
| 50 | |
| 51 | pub fn derived :: p: Pair<Int> -> Bool |
| 52 | { |
| 53 | p == Pair(1, 2) |
| 54 | } |
| 55 | |
| 56 | @derive Eq |
| 57 | pub type Holder //~ ERROR E0410 field of type `fn(Int) -> Int` |
| 58 | { Holder(fn(Int) -> Int) } |
| 59 | |
| 60 | @derive Clone |
| 61 | pub type Uncloneable //~ ERROR E0408 cannot be derived |
| 62 | { Uncloneable } |
| 63 | |
| 64 | impl Eq<List<Int>> {} //~ ERROR E0409 distinct type variables |
| 65 | |
| 66 | fn ambiguous :: |
| 67 | { |
| 68 | show (todo ()) //~ ERROR E0403 cannot tell |
| 69 | } |
| 70 | fn todo :: |
| 71 | { |
| 72 | todo () |
| 73 | } |
| 74 | |
| 75 | // `<>` needs `Semigroup` (ADR 0027): Ints have none, and both sides have |
| 76 | // one type. |
| 77 | fn add_digits :: |
| 78 | { |
| 79 | 1 <> 2 //~ ERROR E0401 `Int` does not implement `Semigroup` |
| 80 | } |
| 81 | fn mixed :: |
| 82 | { |
| 83 | "a" <> 1 //~ ERROR E0202 expected `String`, found `Int` |
| 84 | } |