diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index 94de770..c9ac403 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -7,10 +7,6 @@ const basePath: string = Astro.props.basePath; const entryPath = is_index_file(entry.path)? "": entry.path; const entryUrl = basePath + entryPath + (entryPath.endsWith("/")? "" : "/"); -console.table({ - basePath, - entryPath, -}) function is_index_file(p) { return p.endsWith("index") @@ -35,7 +31,7 @@ function is_index_file(p) { entry.children && ( <>
+
+
diff --git a/src/pages/learn/classes/static.mdx b/src/pages/en/latest/learn/classes/static.mdx
similarity index 86%
rename from src/pages/learn/classes/static.mdx
rename to src/pages/en/latest/learn/classes/static.mdx
index aa20eb8..e5da8d5 100644
--- a/src/pages/learn/classes/static.mdx
+++ b/src/pages/en/latest/learn/classes/static.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Static
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Static in classes
diff --git a/src/pages/en/latest/learn/classes/visibility.mdx b/src/pages/en/latest/learn/classes/visibility.mdx
new file mode 100644
index 0000000..09a4bf9
--- /dev/null
+++ b/src/pages/en/latest/learn/classes/visibility.mdx
@@ -0,0 +1,7 @@
+---
+layout: "../_wrapper.astro"
+title: Visibility
+---
+import Code from "@/components/Code.astro"
+
+# Visibility
diff --git a/src/pages/learn/data-structures/arrays.mdx b/src/pages/en/latest/learn/data-structures/arrays.mdx
similarity index 87%
rename from src/pages/learn/data-structures/arrays.mdx
rename to src/pages/en/latest/learn/data-structures/arrays.mdx
index 713df56..b4502a1 100644
--- a/src/pages/learn/data-structures/arrays.mdx
+++ b/src/pages/en/latest/learn/data-structures/arrays.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Arrays
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Arrays
diff --git a/src/pages/learn/data-structures/enums.mdx b/src/pages/en/latest/learn/data-structures/enums.mdx
similarity index 89%
rename from src/pages/learn/data-structures/enums.mdx
rename to src/pages/en/latest/learn/data-structures/enums.mdx
index e6cba14..0427ebf 100644
--- a/src/pages/learn/data-structures/enums.mdx
+++ b/src/pages/en/latest/learn/data-structures/enums.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Enums
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Enums
diff --git a/src/pages/learn/data-structures/maps.mdx b/src/pages/en/latest/learn/data-structures/maps.mdx
similarity index 96%
rename from src/pages/learn/data-structures/maps.mdx
rename to src/pages/en/latest/learn/data-structures/maps.mdx
index d48067b..a9b5f29 100644
--- a/src/pages/learn/data-structures/maps.mdx
+++ b/src/pages/en/latest/learn/data-structures/maps.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Maps
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Maps
diff --git a/src/pages/learn/data-structures/tuples.mdx b/src/pages/en/latest/learn/data-structures/tuples.mdx
similarity index 75%
rename from src/pages/learn/data-structures/tuples.mdx
rename to src/pages/en/latest/learn/data-structures/tuples.mdx
index a93701a..5316f41 100644
--- a/src/pages/learn/data-structures/tuples.mdx
+++ b/src/pages/en/latest/learn/data-structures/tuples.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Tuples
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Tuples
diff --git a/src/pages/learn/data-structures/unions.mdx b/src/pages/en/latest/learn/data-structures/unions.mdx
similarity index 91%
rename from src/pages/learn/data-structures/unions.mdx
rename to src/pages/en/latest/learn/data-structures/unions.mdx
index 4a661df..15d77c9 100644
--- a/src/pages/learn/data-structures/unions.mdx
+++ b/src/pages/en/latest/learn/data-structures/unions.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Tagged unions
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Tagged unions
diff --git a/src/pages/learn/error-handling/null.mdx b/src/pages/en/latest/learn/error-handling/null.mdx
similarity index 96%
rename from src/pages/learn/error-handling/null.mdx
rename to src/pages/en/latest/learn/error-handling/null.mdx
index 996c793..1755bb5 100644
--- a/src/pages/learn/error-handling/null.mdx
+++ b/src/pages/en/latest/learn/error-handling/null.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Nullable types
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Nullable types
diff --git a/src/pages/learn/error-handling/try.mdx b/src/pages/en/latest/learn/error-handling/try.mdx
similarity index 96%
rename from src/pages/learn/error-handling/try.mdx
rename to src/pages/en/latest/learn/error-handling/try.mdx
index bad72cd..eaeca71 100644
--- a/src/pages/learn/error-handling/try.mdx
+++ b/src/pages/en/latest/learn/error-handling/try.mdx
@@ -1,9 +1,9 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Try/Exceptions
---
-import InteractiveCode from "../../../components/InteractiveCode.astro";
-import Code from "../../../components/Code.astro"
+import InteractiveCode from "@/components/InteractiveCode.astro";
+import Code from "@/components/Code.astro"
# Try/exceptions
diff --git a/src/pages/learn/flow-control/blocks.mdx b/src/pages/en/latest/learn/flow-control/blocks.mdx
similarity index 78%
rename from src/pages/learn/flow-control/blocks.mdx
rename to src/pages/en/latest/learn/flow-control/blocks.mdx
index 95dd5db..0ee56d3 100644
--- a/src/pages/learn/flow-control/blocks.mdx
+++ b/src/pages/en/latest/learn/flow-control/blocks.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Blocks
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Blocks
diff --git a/src/pages/learn/flow-control/conditionals.mdx b/src/pages/en/latest/learn/flow-control/conditionals.mdx
similarity index 89%
rename from src/pages/learn/flow-control/conditionals.mdx
rename to src/pages/en/latest/learn/flow-control/conditionals.mdx
index 9ef5199..cf2aad0 100644
--- a/src/pages/learn/flow-control/conditionals.mdx
+++ b/src/pages/en/latest/learn/flow-control/conditionals.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Conditionals
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Conditionals
diff --git a/src/pages/learn/flow-control/loops.mdx b/src/pages/en/latest/learn/flow-control/loops.mdx
similarity index 92%
rename from src/pages/learn/flow-control/loops.mdx
rename to src/pages/en/latest/learn/flow-control/loops.mdx
index 7c1c88b..a9c69f7 100644
--- a/src/pages/learn/flow-control/loops.mdx
+++ b/src/pages/en/latest/learn/flow-control/loops.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Loops
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Loops
diff --git a/src/pages/learn/flow-control/match.mdx b/src/pages/en/latest/learn/flow-control/match.mdx
similarity index 86%
rename from src/pages/learn/flow-control/match.mdx
rename to src/pages/en/latest/learn/flow-control/match.mdx
index de79cd5..0bca689 100644
--- a/src/pages/learn/flow-control/match.mdx
+++ b/src/pages/en/latest/learn/flow-control/match.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Match
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Match
diff --git a/src/pages/learn/functions/declaration.mdx b/src/pages/en/latest/learn/functions/declaration.mdx
similarity index 96%
rename from src/pages/learn/functions/declaration.mdx
rename to src/pages/en/latest/learn/functions/declaration.mdx
index 5e01490..9f7ba7e 100644
--- a/src/pages/learn/functions/declaration.mdx
+++ b/src/pages/en/latest/learn/functions/declaration.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Declaration
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Declaration
diff --git a/src/pages/learn/functions/higher-order.mdx b/src/pages/en/latest/learn/functions/higher-order.mdx
similarity index 83%
rename from src/pages/learn/functions/higher-order.mdx
rename to src/pages/en/latest/learn/functions/higher-order.mdx
index e5dbd9e..78f4b24 100644
--- a/src/pages/learn/functions/higher-order.mdx
+++ b/src/pages/en/latest/learn/functions/higher-order.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Higher Order Functions
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Higher Order functions
diff --git a/src/pages/learn/functions/lambdas.mdx b/src/pages/en/latest/learn/functions/lambdas.mdx
similarity index 94%
rename from src/pages/learn/functions/lambdas.mdx
rename to src/pages/en/latest/learn/functions/lambdas.mdx
index 2ece501..b85f439 100644
--- a/src/pages/learn/functions/lambdas.mdx
+++ b/src/pages/en/latest/learn/functions/lambdas.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Lambdas
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Lambdas / Anonymous functions
diff --git a/src/pages/learn/functions/parameters.mdx b/src/pages/en/latest/learn/functions/parameters.mdx
similarity index 94%
rename from src/pages/learn/functions/parameters.mdx
rename to src/pages/en/latest/learn/functions/parameters.mdx
index 09252e2..4ca02b5 100644
--- a/src/pages/learn/functions/parameters.mdx
+++ b/src/pages/en/latest/learn/functions/parameters.mdx
@@ -1,8 +1,8 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Function parameters
---
-import Code from "../../../components/Code.astro"
+import Code from "@/components/Code.astro"
# Function parameters
diff --git a/src/pages/learn/templating/components.mdx b/src/pages/en/latest/learn/templating/components.mdx
similarity index 95%
rename from src/pages/learn/templating/components.mdx
rename to src/pages/en/latest/learn/templating/components.mdx
index 0b29cca..aea8419 100644
--- a/src/pages/learn/templating/components.mdx
+++ b/src/pages/en/latest/learn/templating/components.mdx
@@ -1,9 +1,9 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Components
---
-import Code from "../../../components/Code.astro"
-import Info from "../../../components/docs/Info.astro"
+import Code from "@/components/Code.astro"
+import Info from "@/components/docs/Info.astro"
# Components
diff --git a/src/pages/learn/templating/control-flow.mdx b/src/pages/en/latest/learn/templating/control-flow.mdx
similarity index 86%
rename from src/pages/learn/templating/control-flow.mdx
rename to src/pages/en/latest/learn/templating/control-flow.mdx
index 1246251..279d2cf 100644
--- a/src/pages/learn/templating/control-flow.mdx
+++ b/src/pages/en/latest/learn/templating/control-flow.mdx
@@ -1,9 +1,9 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Control flow
---
-import Code from "../../../components/Code.astro"
-import Info from "../../../components/docs/Info.astro"
+import Code from "@/components/Code.astro"
+import Info from "@/components/docs/Info.astro"
# Control flow
diff --git a/src/pages/learn/templating/intro.mdx b/src/pages/en/latest/learn/templating/intro.mdx
similarity index 96%
rename from src/pages/learn/templating/intro.mdx
rename to src/pages/en/latest/learn/templating/intro.mdx
index f8bce58..10f7f4c 100644
--- a/src/pages/learn/templating/intro.mdx
+++ b/src/pages/en/latest/learn/templating/intro.mdx
@@ -1,9 +1,9 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Introduction
---
-import Code from "../../../components/Code.astro"
-import Info from "../../../components/docs/Info.astro"
+import Code from "@/components/Code.astro"
+import Info from "@/components/docs/Info.astro"
# THP templating
diff --git a/src/pages/learn/templating/props.mdx b/src/pages/en/latest/learn/templating/props.mdx
similarity index 93%
rename from src/pages/learn/templating/props.mdx
rename to src/pages/en/latest/learn/templating/props.mdx
index a50eb9b..ccf6950 100644
--- a/src/pages/learn/templating/props.mdx
+++ b/src/pages/en/latest/learn/templating/props.mdx
@@ -1,9 +1,9 @@
---
-layout: ../../../layouts/DocsLayout.astro
+layout: "../_wrapper.astro"
title: Props
---
-import Code from "../../../components/Code.astro"
-import Info from "../../../components/docs/Info.astro"
+import Code from "@/components/Code.astro"
+import Info from "@/components/docs/Info.astro"
# Props
diff --git a/src/pages/learn/basics/comments.mdx b/src/pages/learn/basics/comments.mdx
deleted file mode 100644
index c06b020..0000000
--- a/src/pages/learn/basics/comments.mdx
+++ /dev/null
@@ -1,61 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Comments
----
-import Code from "../../../components/Code.astro"
-
-# Comments
-
-THP supports single and multi line comments:
-
-
-## Single line
-
-Begin with double slash `//` and continue until the end of the line.
-
-
-
-
-## Multi line
-
-These begin with `/*` and end with `*/`. Everything in between is ignored.
-
-Multi line comments can be nested in THP.
-
-
-
-
-
-## Documentation comments
-
-Documentation comments use triple slashes `///`.
-These use [CommonMark Markdown](https://commonmark.org/) syntax.
-
-
-
-
diff --git a/src/pages/learn/basics/datatypes.mdx b/src/pages/learn/basics/datatypes.mdx
deleted file mode 100644
index 45ea586..0000000
--- a/src/pages/learn/basics/datatypes.mdx
+++ /dev/null
@@ -1,86 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Datatypes
----
-import Code from "../../../components/Code.astro"
-
-# Datatypes
-
-THP requires that all datatypes start their name with an
-uppercase letter.
-
-The following are basic datatypes.
-
-## Int
-
-Same as php int
-
-
-
-// TODO: Make it a compile error to have leading zeroes,
-and force users to use `0o` for octal
-
-
-## Float
-
-Same as php float
-
-
-
-
-
-## String
-
-THP strings use **only** double quotes. Single quotes are
-used elsewhere.
-
-
-
-Strings have interpolation with `{}`.
-
-
-
-Unlike PHP, THP strings are concatenated with `++`, not with `.`.
-This new operator implicitly converts any operator into a string.
-
-
-
-The plus operator `+` is reserved for numbers.
-
-
-## Bool
-
-THP booleans are `true` and `false`. They are case sensitive,
-**only lowercase.**
-
-
-
diff --git a/src/pages/learn/basics/hello-world.mdx b/src/pages/learn/basics/hello-world.mdx
deleted file mode 100644
index 55107b3..0000000
--- a/src/pages/learn/basics/hello-world.mdx
+++ /dev/null
@@ -1,45 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Hello world
----
-import InteractiveCode from "../../../components/InteractiveCode.astro";
-import Code from "../../../components/Code.astro"
-
-# Hello, world!
-
-## THP source code
-
-Unlike PHP, THP code is written directly. There is no need to use any `
-
-Then run `thp hello.thp` from your terminal.
-
-
-## Instruction separation
-
-THP uses whitespace to determine when a statement is over. In short,
-where PHP uses a semicolon `;`, THP uses a newline.
-
-```php
-echo("A");
-echo("B");
-echo("C");
-```
-
-
-
-As a consequence of this, there can only be 1 statement per line.
-
diff --git a/src/pages/learn/basics/operators.mdx b/src/pages/learn/basics/operators.mdx
deleted file mode 100644
index 96cf380..0000000
--- a/src/pages/learn/basics/operators.mdx
+++ /dev/null
@@ -1,120 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Operators
----
-import Code from "../../../components/Code.astro"
-
-# Operators
-
-
-Most of the PHP operators are present in THP.
-
-## Numbers
-
-
-
-**There are no prefix/postfix increment operators** (`++`, `--`),
-use `+=` or `-=` instead.
-
-
-
-### Comparison
-
-These operators will not do implicit type conversion. They can
-only be used with same datatypes.
-
- v2
-v1 >= v2
-`} />
-
-There is only `==` and `!=`. They are equivalent to `===` and `!==`.
-
-
-
-
-### Bitwise
-
-TBD
-
-
-
-## Strings
-
-Strings **do not use `.`** for concatenation. They use `++`.
-
-
-
-This new operator **implicitly converts** types to string
-
-
-
-
-## Boolean
-
-These operators work **only with booleans**, they do not perform
-type coercion.
-
-
-
-## Ternary
-
-There is no ternary operator. See [Conditionals](/learn/flow-control/conditionals) for alternatives.
-
-
-## Null
-
-These are detailed in their section: [Nullable types](/learn/error-handling/null)
-
-
-
-
-
diff --git a/src/pages/learn/basics/variables.mdx b/src/pages/learn/basics/variables.mdx
deleted file mode 100644
index 9ac9178..0000000
--- a/src/pages/learn/basics/variables.mdx
+++ /dev/null
@@ -1,98 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Variables
-
----
-import Code from "../../../components/Code.astro"
-
-# Variables
-
-THP distinguishes between mutable and immutable variables.
-
-Variables must be declared in THP to avoid issues with scoping and
-to know if they are mutable/immutable.
-It's a compile error to use undeclared variables.
-
-Variable names **don't** start with a dollar sign `$`.
-
-Variable names **must** begin with a lowercase letter or an underscore.
-Then they may contain lowercase/uppercase letters, numbers and underscores.
-
-As a regex: `[a-z_][a-zA-Z0-9_]*`
-
-## Immutable variables
-
-Defined with `val`, followed by a variable name and a value.
-
-
-
-It's a compile error to attempt to modify it
-
-
-
-
-
-### Datatype annotation
-
-Written after the `val` keyword but before the variable name.
-
-
-
-When annotating an immutable variable the `val` keyword is optional
-
-
-
-This means that if a variable only has a datatype, it is immutable.
-
-It is a compile error to declare a variable of a datatype,
-but use another.
-
-
-
-
-## Mutable variables
-
-Defined with `var`, followed by a variable name and a value.
-
-
-
-### Datatype annotation
-
-Written after the `var` keywords but before the variable name.
-
-
-
-When annotating a mutable variable the keyword `var` is still **required**.
-
-
-
-
-
diff --git a/src/pages/learn/cheatsheet.mdx b/src/pages/learn/cheatsheet.mdx
deleted file mode 100644
index bd35b03..0000000
--- a/src/pages/learn/cheatsheet.mdx
+++ /dev/null
@@ -1,230 +0,0 @@
----
-layout: ../../layouts/DocsLayout.astro
-title: Cheatsheet
-disable_container: true
----
-import TwoColumn from "../../components/TwoColumn.astro"
-import Code from "../../components/Code.astro"
-
-# Language cheatsheet
-
-Comparisons to PHP are noted.
-
-
-
-
-
-```php
-
-
-
-
-
-## Variables
-
-
-
-
-
-
-```php
-
-
-## Datatypes
-
-
-
- ```php
-
- $name = 'Jane';
-
- $full_name = "$name Doe";
-
- $age = 25;
- $interest = 3.22;
-
-
-
- $invalid = 0755;
- $valid = 0o755;
-
- // PHP allows true/false in any case, for some reason
- $has_a_cute_dress = TrUe;
- ```
-
-
-
-
-
- ```php
-
- print("Hello " . "world");
-
-
- $res = 1 + 2 - 3 * 4 % 5;
-
- res += 2;
- res -= 2;
- res *= 2;
- res /= 2;
- res %= 2;
-
-
- ++res;
- res--;
- ```
-
-
-## Flow control
-
-
-
-
- ```php
-
- if (age < 18) {
- print("Not allowed");
- } else if (age === 18) {
- print("Allowed, barely");
- } else {
- print("Allowed");
- }
-
-
-
-
-
-
-
- $gift = "";
- if (prefers_silver) {
- $gift = "silver necklace";
- } else {
- $gift = "gold necklace";
- }
- ```
-
-
-
-
-
-
-
-
-
-
- ```php
- ```
-
diff --git a/src/pages/learn/classes/abstract.mdx b/src/pages/learn/classes/abstract.mdx
deleted file mode 100644
index a467228..0000000
--- a/src/pages/learn/classes/abstract.mdx
+++ /dev/null
@@ -1,9 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Abstract
----
-import Code from "../../../components/Code.astro"
-
-# Abstract
-
-
diff --git a/src/pages/learn/classes/readonly.mdx b/src/pages/learn/classes/readonly.mdx
deleted file mode 100644
index 83dc4b0..0000000
--- a/src/pages/learn/classes/readonly.mdx
+++ /dev/null
@@ -1,15 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Readonly
----
-import Code from "../../../components/Code.astro"
-
-# Readonly
-
-
-
-
diff --git a/src/pages/learn/classes/visibility.mdx b/src/pages/learn/classes/visibility.mdx
deleted file mode 100644
index 8c5bce1..0000000
--- a/src/pages/learn/classes/visibility.mdx
+++ /dev/null
@@ -1,7 +0,0 @@
----
-layout: ../../../layouts/DocsLayout.astro
-title: Visibility
----
-import Code from "../../../components/Code.astro"
-
-# Visibility
diff --git a/src/pages/learn/ideas/idea_1.md b/src/pages/learn/ideas/idea_1.md
deleted file mode 100644
index cb35fec..0000000
--- a/src/pages/learn/ideas/idea_1.md
+++ /dev/null
@@ -1,251 +0,0 @@
-# Idea 1
-
-
-let mut x = 20
-let y = 30
-
-type Something = ...
-
-Something s1 = ...
-Something s2 = s1
-
-
-// Passes `some` by reference, but it's immutable. Cannot call mutable methods
-// or use it in mutable operations
-fun do_something(Something some) -> Bool {}
-do_something(s1)
-
-// Passes `some` by reference, and it's mutable. Can call mutable methods
-// or use it in mutable operations
-fun do_something(&Something some) -> Bool {}
-do_something(&s1)
-
-
-let mut arr1 = Array(10, 20, 30)
-let mut arr2 = &arr1
-
-
- Owned/Reference Mutable
-Type Owned n
-&Type Reference n
-mut Type Owned y
-&mut Type Reference y
-
-
- Copy/Reference Mutable Equivalent
-Some Copy n 1 (technically) references the other data
-&Some Reference n 1 References the other data
-mut Some Copy y 2 Creates a __mutable__ copy
-&mut Some Reference y 3 References the other data, __mutable__
-
-
-## `Array[A]::map`
-
-```thp
-fun map[B](this, (A) -> B callback) -> Array[B]
-```
-
-Applies `callback` to all the elements of this array, and
-returns those new values in a new array.
-
-### Example
-
-```thp
-let numbers = Array(1, 2, 3, 4, 5)
-
-let numbers_squared = numbers.map {it ** 2}
-
-print(numbers_squared) // Array(1, 4, 9, 16, 25)
-
-numbers.map(fun(v) {
- v - 2
-})
-```
-
-
-
-## `Array[A]::reduce`
-
-```thp
-fun reduce[B](
- this,
- B initial,
- (A previous, B current) -> B callback,
-) -> B
-```
-
-Iteratively reduce the array to a single value using `callback`.
-
-
-### Example
-
-```thp
-let numbers = Array(1, 2, 3, 4, 5)
-
-let sum = numbers.reduce(0, \+)
-let sum = numbers.reduce(0) {$1 + $2}
-let sum = numbers.reduce(0, fun(prev, curr) {prev + curr})
-
-print(sum) // 15
-```
-
-
-```thp
-let numbers = Array(1, 2, 3, 4, 5)
-
-let sum = numbers.reduce("", fun(prev, curr) {prev + curr})
-
-let sum = numbers.reduce("") {prev, curr -> prev + curr}
-
-print(sum) // "12345"
-```
-
-
-```thp
-// Functor
-
-fun fmap(
- (A) -> B,
- f[A],
-) -> f[B]
-
-fun (<$)(
- A,
- f[B],
-) -> f[A]
-
-
-// Applicative
-
-fun pure(A) -> f[A]
-
-fun (<*>)(
- f[A -> B],
- f[A],
-) -> f[B]
-
-fun (*>)(
- f[_],
- f[B],
-) -> f[B]
-
-fun (<*)(
- f[A],
- f[_],
-) -> f[A]
-
-
-// Monad
-
-fun (>>=)[m, A, B](
- m[A],
- (A) -> m[B],
-) -> m[B]
-
-
-(Array[Int], Int -> Array[String]) -> Array[String]
-
-let result = Array(1, 2, 3, 4, 5) >>= {Array($.into[String]())}
-
-print(result) // Array("1", "2", "3", "4", "5")
-```
-
-
-```thp
-Option[Int] result = "322".try_into()
-Option[Int] result_halved = result >>= {Some($ / 2)}
-
-print(result_halved) // Some(161)
-
-
-Option[Int] result = "abc".try_into()
-Option[Int] result_halved = result >>= {Some($ / 2)}
-
-print(result_halved) // None
-```
-
-```thp
-fun (<$>)[m, A, B](
- (A) -> B,
- m[A],
-) -> m[B]
-
-
-fun half(Int x) -> Int {
- x / 2
-}
-
-
-Option[Int] result = "322".try_into()
-Option[Int] result_halved = result <$> half
-
-print(result_halved) // Some(161)
-
-
-Option[Int] result = "abc".try_into()
-Option[Int] result_halved = result <$> half
-
-print(result_halved) // None
-```
-
-```thp
-fun (>>)[A, B, C](
- (A) -> B,
- (B) -> C,
-) -> (A) -> C
-
-let f1 = add1 >> times2
-
-f1(5) // 12
-```
-
-
-
-```thp
-function_call[Datatype](param1, param2) {
- // lambda
-}
-
-function_call([arr1, arr2])
-function_call[Datatype]([arr1, arr2])
-
-
-fun test[A, B](A a, B b) -> B {}
-
-
-Array[String] v = 20
-
-val x = Obj {
- Array[Int] x: [1, 2, 3]
-}
-
-value + [1, 2, 3]
-
-value + [Int]
-
-
-value[0]
-
-
-let functions = [
- {0},
- {1},
- {2},
-]
-
-let index = 0
-
-functions[index]()
-
-
-
-```
-
-```thp
-fun main()
-{
- // Using the turbofish operator
- let result = "42".parse[Int]()
-}
-```
-
diff --git a/src/pages/learn/index.mdx b/src/pages/learn/index.mdx
deleted file mode 100644
index 5b59ff1..0000000
--- a/src/pages/learn/index.mdx
+++ /dev/null
@@ -1,305 +0,0 @@
----
-layout: ../../layouts/DocsLayout.astro
-title: Welcome
-pagesLayout:
-- path: index
-- path: install
-- path: cheatsheet
-- path: basics
- title: Basics
- children:
- - path: hello-world
- - path: comments
- - path: variables
- - path: datatypes
- - path: operators
-- path: flow-control
- title: Flow control
- children:
- - path: conditionals
- - path: loops
- - path: match
- - path: blocks
-- path: data-structures
- title: Data structures
- children:
- - path: tuples
- - path: arrays
- - path: maps
- - path: enums
- - path: unions
-- path: functions
- title: Functions
- children:
- - path: declaration
- - path: parameters
- - path: higher-order
- - path: lambdas
-- path: error-handling
- title: Error handling
- children:
- - path: "null"
- - path: try
-- path: classes
- title: Classes
- children:
- - path: definition
- - path: constructor
- - path: inheritance
- - path: static
- - path: visibility
- - path: readonly
- - path: abstract
- - path: interfaces
- - path: anonymous
- - path: magic
-- path: templating
- title: Templating
- children:
- - path: intro
- - path: components
- - path: props
- - path: control-flow
----
-import InteractiveCode from "../../components/InteractiveCode.astro";
-import Code from "../../components/Code.astro"
-
-
-# Welcome
-
-Welcome to the documentation of the THP programming languague.
-
-THP is a new programming language that compiles to PHP.
-
-![Accurate visual description of THP](/img/desc_thp.jpg)
-
-
-This page details the main design desitions of the language,
-if you want to install THP go to the [installation guide](install)
-
-
-## Why?
-
-PHP is an old language. It has been growing since 1995, adopting a
-lot of features from many places like C, Perl, Java, etc. This was
-done in a very inconsistent way, as detailed by Eevee in their article
-[PHP: a fractal of bad design.](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)
-
-Along the years PHP has been improving. PHP added classes, exceptions,
-interfaces, traits, type hints and checks, functional features,
-reflection, etc., etc. However, by building on top of the existing
-language without a clear design philosophy, and by keeping backwards
-compatibility, we ended up with a messy language. The article
-above goes into detail about this.
-
-In spite of this, PHP has remained widely used and loved, in a
-weird way (I'd say in the same way that people love JavaScript),
-and at the time of writing PHP 8.3 is available. However,
-PHP is to my eyes fundamentally flawed, and cannot get up to
-date without completely breaking what came before.
-
-This is where THP comes in. I wanted a modern language
-that could run in the same environment that PHP does.
-And I quickly realized that building on top of PHP
-in the same way that TypeScript did for JavaScript would be
-detrimental. It would be better to create a completely new
-language, treat PHP source code as a "low level" compilation
-target, and focus entirely on the new language.
-
-This new language would be mainly inspired by what **I** consider the best
-designed languages out there: Rust as a baseline, Zig for
-its null and error handling and Kotlin for its OOP features.
-In a way, PHP will be adapted to, say, Rust's syntax and semantics,
-instead of having Rust adapt to PHP.
-
-In pursue of this THP **will** ditch many things about PHP,
-in name of consistency. These are things that PHP devs are
-used to doing, but that I consider bad practices, hacks or
-workarounds. One example of this are variable variables on PHP:
-`$$variable`.
-
-Another critical point of THP is type safety. It is a goal
-to approach the same level of type safety that have compiled
-languages like Java/Go/Rust, and leave aside dynamic typing
-as much as possible. Types cannot be turned off, you cannot
-use `Any` to avoid typechecking, and so on.
-
-Finally, there are some additions to the language that I consider
-essential today: A good, unified LSP, type definitions,
-accesible documentation, an opinionated code formatter
-and plugins for major editors like VSCode and Neovim.
-
-
-
-
-
-## Goals
-
-- Bring static typing to PHP: Generics, type checks at compile and runtime, etc.
-- Reduce implicit type conversion to a minimum.
-- Remove the inconsistencies in the language.
-- Organize the PHP stdlib.
-- Have a clear distinctions between Arrays, Tuples, Maps and Sets.
-- Implement Union types
-- Create a **consistent** language.
-- Have typings for popular libraries (like TS's `.d.ts`).
-- Have a simple instalation and configuration (requiring just Composer or a binary).
-- Ship a **_blazingly fast_**, native binary, ~~written in Rust~~ now rewritten in Zig!.
-- Support in-place compilation.
-- Implement a Language Server.
-- Implement an opinionated code formatter.
-
-![Friendship ended with Rust, now Zig is my best friend.](/img/mudasir.jpg)
-
-
-## Not goals
-
-These are **not** things that THP wants to solve or implement
-
-- Be what TypeScript is for JavaScript (PHP with types).
-- Strictly adhere to PHP syntax/conventions.
-
-THP **_intentionally_** uses a different syntax from PHP to signal
-that it is a different language, and has different semantics.
-
-
-## Some differences with PHP
-
-```php
-// PHP
-$has_key = str_contains($haystack, 'needle');
-print("has key? " . $has_key);
-```
-
-
-
-- Explicit variable declaration
-- No `$` for variable names (and thus no `$$variable`, use a map instead)
-- No semicolons
-- Use methods on common datatypes
-- Strings use only double quotes
-- String concatenation with `+`
-
-
-
-
-
-```php
-// PHP
-$obj = [
- 'names' => ['Toni', 'Stark'],
- 'age' => 33,
- 'numbers' => [32, 64, 128]
-]
-```
-
-
-
-- Tuples, Arrays, Sets, Maps are clearly different
-- JSON-like object syntax
-
-
-
-
-```php
-// PHP
-$cat = new Cat("Michifu", 7);
-$cat->meow();
-```
-
-
-
-
-- Instantiate classes without `new`
-- Use dot `.` instead of arrow `->` syntax
-
-
-
-
-```php
-// PHP
-use \Some\Deeply\Nested\Class
-use \Some\Deeply\Nested\Interface
-```
-
-
-
-
-- Different module syntax
-- Explicit module declaration
-- PSR-4 required
-- No `include`, `include_once`, `require` or `require_once`
-
-
-
-
-
-Other things:
-
-- Pattern matching
-- ADTs
-
-
-## Runtime changes
-
-Where possible THP will compile to available PHP functions/classes/methods/etc.
-
-For example:
-
- 18
- {
- "Welcome, {person.name}"
- }
- case Some(person)
- {
- "I'm sorry {person.name}, you need to be 18 or older"
- }
- case None
- {
- "Nobody is here"
- }
-`} />
-
-```php
-// Would compile to:
-$greeting = null;
-$_person = get_person();
-if ($_person !== null) {
- if ($_person["age"] > 18) {
- $greeting = "Welcome, " . $_person["name"];
- }
- else {
- $greeting = "I'm sorry " . $_person["name"] . ", you need to be 18 or older";
- }
-}
-else {
- $greeting = "Nobody is here";
-}
-```
-
-However, more advanced datatypes & helper functions will require a sort of
-runtime (new classes/functions/etc) or abuse the language's syntax/semantics.
-
-
diff --git a/src/pages/learn/install.md b/src/pages/learn/install.md
deleted file mode 100644
index 39aeae7..0000000
--- a/src/pages/learn/install.md
+++ /dev/null
@@ -1,28 +0,0 @@
----
-layout: ../../layouts/DocsLayout.astro
-title: Install
----
-
-# Install
-
-**THP is technically usable.**
-
-## From source (*nix)
-
-Requires Rust installed.
-
-Clone [the repo](https://git.araozu.dev/fernando/thp) and run
-`cargo build --release`. You'll have a `thp` binary on
-`target/release/thp`, run it and see for yourself.
-
-
-## Binary
-
-Goal: Install THP with a single binary. Assumes that php and composer is
-available.
-
-
-## With composer
-
-TBD: Install THP with `composer require thp`
-