tobogganSe connecter

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.

84 lignes · 1449 octetsBrut · Historique
1pub type Color { Red, Green }
2
3impl Show<Color>
4{
5 fn show :: c
6 {
7 match c { Red -> "red", Green -> "green" }
8 }
9}
10
11pub fn shown :: -> String
12{
13 show Red
14}
15
16pub type Point { Point(x: Int, y: Int) }
17
18impl 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
31impl Show<Point> //~ ERROR E0407 missing method `show`
32{}
33
34impl Show<Color> {} //~ ERROR E0404 implemented more than once
35
36pub fn no_impl :: -> Bool
37{
38 (fn x { x }) == (fn x { x }) //~ ERROR E0401 does not implement `Eq`
39}
40
41pub 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
49pub type Pair<a> { Pair(a, a) }
50
51pub fn derived :: p: Pair<Int> -> Bool
52{
53 p == Pair(1, 2)
54}
55
56@derive Eq
57pub type Holder //~ ERROR E0410 field of type `fn(Int) -> Int`
58{ Holder(fn(Int) -> Int) }
59
60@derive Clone
61pub type Uncloneable //~ ERROR E0408 cannot be derived
62{ Uncloneable }
63
64impl Eq<List<Int>> {} //~ ERROR E0409 distinct type variables
65
66fn ambiguous ::
67{
68 show (todo ()) //~ ERROR E0403 cannot tell
69}
70fn todo ::
71{
72 todo ()
73}
74
75// `<>` needs `Semigroup` (ADR 0027): Ints have none, and both sides have
76// one type.
77fn add_digits ::
78{
79 1 <> 2 //~ ERROR E0401 `Int` does not implement `Semigroup`
80}
81fn mixed ::
82{
83 "a" <> 1 //~ ERROR E0202 expected `String`, found `Int`
84}