Initial commit: MPL specification and M0 documentation
- Complete language specification (math_prog_lang.md) - M0 blocker tracking issue template - Glyph escape sequences reference - Operator precedence table - Example programs from specification - Project README Ready for pre-M0 implementation phase
This commit is contained in:
commit
57efd37df6
15 changed files with 602 additions and 0 deletions
1
examples/01_hello_world.mpl
Normal file
1
examples/01_hello_world.mpl
Normal file
|
|
@ -0,0 +1 @@
|
|||
✎"Hello, World!"
|
||||
3
examples/02_factorial.mpl
Normal file
3
examples/02_factorial.mpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
factorial ≜ λn∈ℕ: n≤1 ⟹ 1 | n×factorial(n-1)
|
||||
result ← factorial(5)
|
||||
✎result
|
||||
6
examples/03_file_processing.mpl
Normal file
6
examples/03_file_processing.mpl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
processFile ≜ λpath: 🖫path ↴ {
|
||||
data ← readFile(path)
|
||||
result ← transform(data)
|
||||
writeFile(result, 🖫"output.txt")
|
||||
⟨"success"|"failed"⟩
|
||||
} ↴ {↯e ⇒ ⟨⊥|e⟩}
|
||||
3
examples/04_concurrent_download.mpl
Normal file
3
examples/04_concurrent_download.mpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
downloadAll ≜ λurls: ∀url∈urls: (
|
||||
fetchData(url) ‖ processData(url)
|
||||
) ⟹ mergeResults()
|
||||
8
examples/05_module_definition.mpl
Normal file
8
examples/05_module_definition.mpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
𝓜 Mathematics ⇒ {
|
||||
π ≜ 3.14159
|
||||
sin ≜ λx∈ℝ: ...
|
||||
cos ≜ λx∈ℝ: ...
|
||||
}
|
||||
|
||||
angle ← π/4
|
||||
result ← Mathematics‧sin(angle)
|
||||
9
examples/06_resource_management.mpl
Normal file
9
examples/06_resource_management.mpl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
databaseQuery ≜ λquery: 〔
|
||||
conn ← database ⊕
|
||||
⌈
|
||||
result ← execute(conn, query)
|
||||
✎"Query executed"
|
||||
result
|
||||
⌉_db_lock
|
||||
conn ⊖
|
||||
〕
|
||||
6
examples/07_metaprogramming.mpl
Normal file
6
examples/07_metaprogramming.mpl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
generateFunction ≜ λname: ⌜
|
||||
λx: x × 2
|
||||
⌝
|
||||
|
||||
doubler ← ⌞generateFunction("doubler")⌟
|
||||
result ← doubler(21)
|
||||
5
examples/08_realtime_system.mpl
Normal file
5
examples/08_realtime_system.mpl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
scheduler ≜ ⟳(
|
||||
tasks ← getPendingTasks()
|
||||
∀task∈tasks: execute(task) ‖ monitor(task)
|
||||
, 100ms
|
||||
)
|
||||
9
examples/09_network_server.mpl
Normal file
9
examples/09_network_server.mpl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
server ≜ λport: 〔
|
||||
socket ← bind(port) ⊕
|
||||
∀request: (
|
||||
data ← ↽_socket request
|
||||
response ← processRequest(data)
|
||||
⇀_socket response
|
||||
) ‖ handleNext()
|
||||
socket ⊖
|
||||
〕
|
||||
4
examples/10_type_safe_database.mpl
Normal file
4
examples/10_type_safe_database.mpl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
User ≜ {name: String, age: ℕ∣age>0, email: String}
|
||||
query ≜ λtable∈Database: ∀row∈table: validateUser(row) ↴ {
|
||||
↯"Invalid user" ⟹ ⊥
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue