Compare commits

..

No commits in common. "733921a2ff2282436a7f0f6adc301ecda275c091" and "1714d7ee767010fda65cee42b891f08f934d53a9" have entirely different histories.

2 changed files with 135 additions and 218 deletions

View File

@ -1,36 +0,0 @@
---
import CodeEditor from "./CodeEditor.astro";
const { title, thpcode, subtitle } = Astro.props;
if (!subtitle) {
throw new Error("subtitle is required");
}
if (!thpcode) {
throw new Error("thpcode is required");
}
if (!title) {
throw new Error("title is required");
}
---
<div>
<div class="bg-c-thp text-c-bg">
<h1 class="container mx-auto font-medium py-8 text-3xl">
{subtitle} <span class="font-black">{title}</span>
</h1>
</div>
<div class="container mx-auto lg:grid lg:grid-cols-2 gap-4">
<div class="px-8 py-12 flex h-full items-center">
<div>
<slot />
</div>
</div>
<div>
<CodeEditor thpcode={thpcode} />
</div>
</div>
</div>

View File

@ -2,7 +2,6 @@
import BaseLayout from "../layouts/BaseLayout.astro"; import BaseLayout from "../layouts/BaseLayout.astro";
import Navbar from "../components/Navbar.astro"; import Navbar from "../components/Navbar.astro";
import CodeEditor from "../components/CodeEditor.astro"; import CodeEditor from "../components/CodeEditor.astro";
import HeroSection from "../components/HeroSection.astro";
--- ---
<BaseLayout> <BaseLayout>
@ -67,11 +66,7 @@ import HeroSection from "../components/HeroSection.astro";
height="14" height="14"
viewBox="0 0 54 14" viewBox="0 0 54 14"
> >
<g <g fill="none" fill-rule="evenodd" transform="translate(1 1)">
fill="none"
fill-rule="evenodd"
transform="translate(1 1)"
>
<circle <circle
cx="6" cx="6"
cy="6" cy="6"
@ -102,10 +97,32 @@ import HeroSection from "../components/HeroSection.astro";
</div> </div>
</div> </div>
<HeroSection <div>
subtitle="We've got" <div class="bg-c-thp text-c-bg">
title="generics" <h1 class="container mx-auto font-medium py-8 text-3xl">
thpcode={` THP is <span class="font-black">actually typed</span>
</h1>
</div>
<div class="container mx-auto lg:grid lg:grid-cols-2 gap-4">
<div class="px-8 py-12 flex h-full items-center">
<div>
THP enforces type safety at compile time and, at the programmer's
request, at runtime.
<br>
<br>
Everything has a type.
There are generics.
No implicit type conversions. No <code>mixed</code>.
No client <code>Any</code> .Type inference included.
<br>
<br>
All possible checks are made at compile time. Runtime checks
have a small performance penalty.
</div>
</div>
<div>
<CodeEditor thpcode={`
Array[Int] numbers = [0, 1, 2, 3, 4, 5] Array[Int] numbers = [0, 1, 2, 3, 4, 5]
numbers.push("7") // Compile error: expected an Int, found a String numbers.push("7") // Compile error: expected an Int, found a String
@ -121,74 +138,10 @@ import HeroSection from "../components/HeroSection.astro";
val result = mock() val result = mock()
// Ok // Ok
val result = mock() as String val result = mock() as String
`} `} />
> </div>
THP enforces type safety at compile time and, at the programmer's </div>
request, at runtime. </div>
<br />
<br />
Everything has a type. There are generics. No implicit type conversions.
No <code>mixed</code>. No client <code>Any</code> .Type inference included.
<br />
<br />
All possible checks are made at compile time. Runtime checks have a small
performance penalty.
</HeroSection>
<HeroSection
subtitle="We've got"
title="tagged unions"
thpcode={`
union DirEntry {
File(String),
Dir(String),
}
val root = DirEntry::Dir("/")
`}
>
Make invalid state irrepresentable.
<br>
Model data in a type-safe way.
<br>
Ensure all cases are handled.
</HeroSection>
<HeroSection
subtitle="We've got"
title="pattern matching"
thpcode={`
match test_file
case DirEntry::File(filename)
if !filename.starts_with(".")
{
print(filename)
}
else
{
print("A valid file was not found")
}
`}
>
Match on values, tuples, enums, unions, types etc.
<br>
Guards available!
</HeroSection>
<HeroSection
subtitle="We've got"
title="null safety"
thpcode={`
String? username = Globals::Post::get("username")
if username? {
// username is a \`String\` here
print("Hello, {username}")
}
`}
>
Nulls are explicit and require handling.
</HeroSection>
<script> <script>
import { thp_highlighter, CodeJar } from "../lexer/highlighter"; import { thp_highlighter, CodeJar } from "../lexer/highlighter";