chore: add simple operation and type examples
This commit is contained in:
4
examples/01_simple_type_checking/01_simple_operations.py
Normal file
4
examples/01_simple_type_checking/01_simple_operations.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
a: int = 3
|
||||||
|
b: int = 4
|
||||||
|
|
||||||
|
c = a + b # -> int
|
||||||
14
examples/01_simple_type_checking/02_simple_types.midas
Normal file
14
examples/01_simple_type_checking/02_simple_types.midas
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
type Meter(float)
|
||||||
|
type Second(float)
|
||||||
|
type MeterPerSecond(float)
|
||||||
|
|
||||||
|
extend Meter {
|
||||||
|
op __add__(Meter) -> Meter
|
||||||
|
op __sub__(Meter) -> Meter
|
||||||
|
op __truediv__(Second) -> MeterPerSecond
|
||||||
|
}
|
||||||
|
|
||||||
|
extend Second {
|
||||||
|
op __add__(Second) -> Second
|
||||||
|
op __sub__(Second) -> Second
|
||||||
|
}
|
||||||
8
examples/01_simple_type_checking/02_simple_types.py
Normal file
8
examples/01_simple_type_checking/02_simple_types.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# type: ignore
|
||||||
|
# ruff: disable [F821]
|
||||||
|
|
||||||
|
midas.using("02_simple_types.midas")
|
||||||
|
|
||||||
|
distance: Meter = 123.45
|
||||||
|
time: Second = 6.7
|
||||||
|
speed = distance / time
|
||||||
Reference in New Issue
Block a user