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.

29 lignes · 872 octetsBrut · Historique
1import std/io
2
3@derive Eq Ord Show Debug Hash Default
4pub type Settings
5{ Settings(name: String, retries: Int, verbose: Bool, tags: List<String>) }
6
7@derive Eq Debug Hash
8pub type Shape { Circle(Int), Square(Int) }
9
10pub fn main :: -> () / <io>
11{
12 let defaults: Settings = default ()
13 io.println (debug defaults)
14 io.println (show defaults)
15 io.println (debug [Circle(1), Square(2)])
16 let custom = Settings(..defaults, name: "prod", retries: 3)
17 io.println (show (custom == defaults) <> " " <> show (custom > defaults))
18 io.println
19 (show (hash custom == hash Settings(..defaults, name: "prod", retries: 3)))
20 io.println (show (hash Circle(1) == hash Square(1)))
21 io.println (show (hash 1 >= 0))
22}
23//> Settings { name: "", retries: 0, verbose: False, tags: [] }
24//> Settings(, 0, False, [])
25//> [Circle(1), Square(2)]
26//> False True
27//> True
28//> False
29//> True