lang_2023/tests/classes.lang

60 lines
983 B
Text
Raw Normal View History

2023-06-03 19:01:03 +03:00
struct \fruit =
| $apple
| $orange
| $banana
2023-03-31 12:10:12 +03:00
2023-06-03 19:01:03 +03:00
struct \optional 'a =
| $some & 'a
| $none
2023-03-31 12:10:12 +03:00
2023-06-03 19:01:03 +03:00
struct \result[#move] 'a 'b =
| & 'a
| $error & 'b
2023-03-31 12:10:12 +03:00
2023-06-03 19:01:03 +03:00
struct \complex[#value] =
& \float
& \float
2023-06-03 19:01:03 +03:00
struct \task =
& name : \string
& duration : \float?
2023-03-31 12:10:12 +03:00
2023-06-03 19:01:03 +03:00
class \employee =
& name : \string
2023-03-31 12:10:12 +03:00
& role :
2023-06-03 19:01:03 +03:00
( | $director
& importance : \float
& share : \float
| $manager
2023-03-31 12:10:12 +03:00
& productivity :
2023-06-03 19:01:03 +03:00
( \productivity
| $.low
| $.average
| $.high
& duration : \float
& sleep-on-work :
( \sleep-on-work
| $..yes
| $..no
2023-03-31 12:10:12 +03:00
))
2023-06-03 19:01:03 +03:00
& salary : \int
| $programmer
& skills : \float
& current-task : \optional[task]
& salary : \int)
2023-03-31 12:10:12 +03:00
2023-06-03 19:01:03 +03:00
class \bag =
2023-03-31 12:10:12 +03:00
&
2023-06-03 19:01:03 +03:00
( | $apple
| $orange
| $banana)
& bag-type :
( | $small
| $medium
& weight-kg : \int
& weight-g : \int
& weight-mg : \int
| $big)
& other-things : \array[something]