Skip to content

Commit c8b7878

Browse files
committed
docs: update introduction
1 parent 589d26d commit c8b7878

File tree

1 file changed

+67
-65
lines changed

1 file changed

+67
-65
lines changed

docs/index.md

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,92 @@
1-
# Saki-Lang
1+
# Introduction
22

33
!!! warning
4-
This project is currently in active elaboration and development, with significant progress yet to be made before it is ready for use.
4+
Saki-lang is currently in a very early stage of design and development, with substantial work required before it reaches a mature state. The prototype interpreter and REPL are still under active development, and no working interpreters are currently available.
5+
6+
Saki is a statically typed, pure functional programming language that integrates dependent types and certain object-oriented constructs, including function overloading and algebraic subtyping. Its design emphasizes simplicity, adopting a C-family syntax while employing a sophisticated type system rooted in Martin-Löf Type Theory. Saki introduces novel features, such as [contract universes](Terms/Contract%20Universe.md) and [superposition types](Definition/Function%20Overloading.md), positioning itself as an experimental platform for investigating advanced type system mechanics and program synthesis. Heavily influenced by [Pikelet](https://github.com/pikelet-lang/pikelet) and [MLsub](https://lptk.github.io/programming/2020/03/26/demystifying-mlsub.html), Saki aims to explore new frontiers in type theory and programming paradigms.
57

68
## Practical Example: Red-Black Tree in Saki
79

810
```scala
911
universe 'LessThan(A: 'Type) = contract {
10-
require (<)(self, A: 'Type): Bool
12+
require (<)(self, A: 'Type): Bool
1113
}
1214

1315
type Option(A: 'Type) = enum {
14-
None
15-
Some(A)
16+
None
17+
Some(A)
1618
}
1719

1820
type Color = enum {
19-
Red
20-
Black
21+
Red
22+
Black
2123
}
2224

2325
type Tree[A: 'LessThan(A)] = enum {
24-
Leaf
25-
Node(Color, A, Tree[A], Tree[A])
26+
Leaf
27+
Node(Color, A, Tree[A], Tree[A])
2628
}
2729

2830
impl [A: 'LessThan(A)] Tree[A] {
29-
def balance(self): Self = match self {
30-
case Self::Node(
31-
Color::Black, valueRight,
32-
Self::Node(
33-
Color::Red, valueTop,
34-
Self::Node(Color::Red, valueLeft, leftLeft, leftRight),
35-
rightLeft
36-
), rightRight
37-
) | Self::Node(
38-
Color::Black, valueRight,
39-
Self::Node(
40-
Color::Red, valueLeft,
41-
leftLeft,
42-
Self::Node(Color::Red, valueTop, leftRight, rightLeft)
43-
), rightRight
44-
) | Self::Node(
45-
Color::Black, valueLeft,
46-
leftLeft,
47-
Self::Node(
48-
Color::Red, valueRight,
49-
Self::Node(Color::Red, valueTop, leftRight, rightLeft),
50-
rightRight
51-
),
52-
) | Self::Node(
53-
Color::Black, valueLeft,
54-
leftLeft,
55-
Self::Node(
56-
Color::Red, valueTop,
57-
leftRight,
58-
Self::Node(Color::Red, valueRight, rightLeft, rightRight),
59-
),
60-
) => Self::Node(
61-
Color::Red, valueTop,
62-
Self::Node(Color::Black, valueLeft, leftLeft, leftRight),
63-
Self::Node(Color::Black, valueRight, rightLeft, rightRight),
64-
)
65-
case node: Self => node
66-
}
31+
def balance(self): Self = match self {
32+
case Self::Node(
33+
Color::Black, valueRight,
34+
Self::Node(
35+
Color::Red, valueTop,
36+
Self::Node(Color::Red, valueLeft, leftLeft, leftRight),
37+
rightLeft
38+
), rightRight
39+
) | Self::Node(
40+
Color::Black, valueRight,
41+
Self::Node(
42+
Color::Red, valueLeft,
43+
leftLeft,
44+
Self::Node(Color::Red, valueTop, leftRight, rightLeft)
45+
), rightRight
46+
) | Self::Node(
47+
Color::Black, valueLeft,
48+
leftLeft,
49+
Self::Node(
50+
Color::Red, valueRight,
51+
Self::Node(Color::Red, valueTop, leftRight, rightLeft),
52+
rightRight
53+
),
54+
) | Self::Node(
55+
Color::Black, valueLeft,
56+
leftLeft,
57+
Self::Node(
58+
Color::Red, valueTop,
59+
leftRight,
60+
Self::Node(Color::Red, valueRight, rightLeft, rightRight),
61+
),
62+
) => Self::Node(
63+
Color::Red, valueTop,
64+
Self::Node(Color::Black, valueLeft, leftLeft, leftRight),
65+
Self::Node(Color::Black, valueRight, rightLeft, rightRight),
66+
)
67+
case node: Self => node
68+
}
6769

68-
def insert(self, newValue: A): Self = match self {
69-
case Self::Leaf => Self::Node(Color::Red, newValue, Self::Leaf, Self::Leaf)
70-
case Self::Node(color, value, left, right) => if newValue < value then {
71-
Self::Node(color, value, left.insert(value), right)
72-
} else if value < newValue then {
73-
Self::Node(color, value, left, right.insert(value))
74-
} else {
75-
Self::Node(color, newValue, left, right)
76-
}
70+
def insert(self, newValue: A): Self = match self {
71+
case Self::Leaf => Self::Node(Color::Red, newValue, Self::Leaf, Self::Leaf)
72+
case Self::Node(color, value, left, right) => if newValue < value then {
73+
Self::Node(color, value, left.insert(value), right)
74+
} else if value < newValue then {
75+
Self::Node(color, value, left, right.insert(value))
76+
} else {
77+
Self::Node(color, newValue, left, right)
7778
}
79+
}
7880

79-
def find(self, value: A): Option(A) = match self {
80-
case Self::Leaf => Option(A)::None
81-
case Self::Node(color, value, left, right) => if newValue < value then {
82-
left.find(value)
83-
} else if value < newValue then {
84-
right.find(value)
85-
} else {
86-
Option(A)::Some(value)
87-
}
81+
def find(self, value: A): Option(A) = match self {
82+
case Self::Leaf => Option(A)::None
83+
case Self::Node(color, value, left, right) => if newValue < value then {
84+
left.find(value)
85+
} else if value < newValue then {
86+
right.find(value)
87+
} else {
88+
Option(A)::Some(value)
8889
}
90+
}
8991
}
9092
```

0 commit comments

Comments
 (0)