Introduction
Floe is a programming language that compiles to TypeScript. It’s designed for TypeScript and React developers who want stronger guarantees without leaving their ecosystem.
Why Floe?
Section titled “Why Floe?”TypeScript allows any, null, undefined, and type assertions. These lead to runtime errors that the type system was supposed to prevent.
Floe removes these and adds features that make correct code easy to write:
- Pipes (
|>) for readable data transformations - Pattern matching (
match) with exhaustiveness checking - Result/Option instead of null/undefined/exceptions
- No
any- useunknownand narrow - No
null/undefined- useOption<T>withSome/None - No classes - use functions and records
What does it look like?
Section titled “What does it look like?”import trusted { useState } from "react"
type Todo { id: string, text: string, done: boolean,}
export fn App() -> JSX.Element { const [todos, setTodos] = useState<Array<Todo>>([])
const completedCount = todos |> filter(.done) |> length
<div> <h1>Todos ({completedCount} done)</h1> </div>}This compiles to clean, readable TypeScript:
import { useState } from "react";
type Todo = { id: string; text: string; done: boolean;};
export function App(): JSX.Element { const [todos, setTodos] = useState<Todo[]>([]);
const completedCount = length(filter(todos, (t) => t.done));
return <div> <h1>Todos ({completed} done)</h1> </div>;}Design Philosophy
Section titled “Design Philosophy”- Familiar syntax - designed to be readable by TypeScript developers
- Plain output - the compiler emits readable TypeScript
- Eject anytime - if you stop using Floe, you have normal
.tsfiles - Strictness is a feature - every restriction exists to prevent a category of bugs