diff --git a/src/components/CodeEditor.astro b/src/components/CodeEditor.astro index b310d07..78e126e 100644 --- a/src/components/CodeEditor.astro +++ b/src/components/CodeEditor.astro @@ -1,11 +1,11 @@ --- import Code from "./Code.astro" -const { thpcode, no_warnings } = Astro.props; +const { thpcode, no_warnings, level } = Astro.props; --- -
+
- +
diff --git a/src/components/HeroSection.astro b/src/components/HeroSection.astro index a0baa0d..b1ff2d6 100644 --- a/src/components/HeroSection.astro +++ b/src/components/HeroSection.astro @@ -1,11 +1,8 @@ --- +import { HighlightLevel } from "../lexer/types"; import CodeEditor from "./CodeEditor.astro"; -const { title, thpcode, subtitle } = Astro.props; - -if (!subtitle) { - throw new Error("subtitle is required"); -} +const { title, thpcode } = Astro.props; if (!thpcode) { throw new Error("thpcode is required"); @@ -17,20 +14,26 @@ if (!title) { ---
-
-

- {subtitle} {title} +
+

+ ✅ {title}

-
+
-
- -
+
diff --git a/src/pages/index.astro b/src/pages/index.astro index 0d7cc3b..d6a0a27 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,18 +4,16 @@ import Navbar from "../components/Navbar.astro"; import HeroSection from "../components/HeroSection.astro"; import { native_highlighter } from "../lexer/highlighter"; import { leftTrimDedent } from "../components/utils"; +import { HighlightLevel } from "../lexer/types"; const thpcode = `union Animal { Dog(String), Cat(String, Int), } -val cat_name = Post::get("cat_name") ?? "Michifu" -val my_cat = Animal::Cat(cat_name, 9) +val my_pet = try Pets::get_first() -try change_fur_color(cat) else die("Not a cat") - -match random_animal() +match my_pet case Dog(name) { print("{name} has 1 live ") @@ -25,7 +23,10 @@ case Cat(name, lives) print("{name} has {lives}") }`; -const [thp_html] = await native_highlighter(leftTrimDedent(thpcode).join("\n")); +const [thp_html] = await native_highlighter( + leftTrimDedent(thpcode).join("\n"), + HighlightLevel.Lexic, +); --- @@ -49,21 +50,18 @@ const [thp_html] = await native_highlighter(leftTrimDedent(thpcode).join("\n")); Inspired by Rust, Zig and Kotlin, THP has a modern syntax, semantics, type system and stdlib.

-
-
-
+
- Tutorial + Learn Install @@ -71,10 +69,10 @@ const [thp_html] = await native_highlighter(leftTrimDedent(thpcode).join("\n"));
-
-
+
+
-
-

+                        
                     
+
+ - THP enforces type safety at compile time and, at the programmer's - request, at runtime. -
-
- Everything has a type. There are generics. No implicit type conversions. - No mixed. No client Any .Type inference included. -
-
- All possible checks are made at compile time. Runtime checks have a small - performance penalty. + Type safety is enforced at compile time. Everything + has a specific type. There is no `mixed`. +
+
+ You can use generics where neccesary.
Make invalid state irrepresentable. -
+
Model data in a type-safe way. -
+
Ensure all cases are handled.
Match on values, tuples, enums, unions, types etc. -
+
Guards available!
- Nulls are explicit and require handling. Types are nullable, and they - are used everywhere they are needed. + Nulls are explicit and require handling. Types can be nullable, + and they must be checked before usage. +
+ The stdlib makes extensive use of them. +
+ + + Exceptions are values and don't disrupt + control flow.

- Nullable types must be explicitly checked before using them. + Errors cannot be ignored, and we have + syntax sugar to ease them.