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.

47 lignes · 884 octetsBrut · Historique
1// A name must denote the kind of thing its position needs.
2
3import std/io
4
5type Shape { Circle(Int), Square(Int) }
6
7effect log
8{
9 fn log :: msg: String -> ()
10}
11
12fn area :: s: Shape -> Int
13{
14 match s { Circle(r) -> 3 * r * r, Square(side) -> side * side }
15}
16
17// A module, a type or a function where a value or constructor is needed
18// (E0109).
19fn module_as_value ::
20{
21 let printer = io //~ ERROR E0109 `io` is a module, not a value
22}
23
24fn type_as_value ::
25{
26 let s = Shape //~ ERROR E0109 `Shape` is a type, trait or effect, not a value
27}
28
29fn function_as_pattern :: s: Shape -> Int
30{
31 match s
32 { io.println(x) -> 0 //~ ERROR E0109 `io.println` is not a constructor
33 }
34}
35
36// A handler clause names an operation (E0112).
37fn handles_a_function :: -> ()
38{
39 handle
40 {
41 log "hi"
42 }
43 with
44 { log m -> ()
45 , area s -> () //~ ERROR E0112 `area` is not an effect operation
46 }
47}