Your First Program
Hello World
Section titled “Hello World”Create a file called hello.fl:
export fn greet(name: string) -> string { `Hello, ${name}!`}
greet("world") |> Console.logCompile it:
floe build hello.flThis produces hello.ts:
export function greet(name: string): string { return `Hello, ${name}!`;}
console.log(greet("world"));A React Component
Section titled “A React Component”Create counter.fl:
import { useState } from "react"
export fn Counter() -> JSX.Element { const [count, setCount] = useState(0)
<div> <p>Count: {count}</p> <button onClick={fn() setCount(count + 1)}>+1</button> </div>}Compile it:
floe build counter.flThis produces counter.tsx, a standard React component that works with any React setup.
Using Pipes
Section titled “Using Pipes”Pipes let you read transformations left-to-right instead of inside-out:
// Without pipes (nested calls)const result = toString(add(multiply(value, 2), 1))
// With pipes (left to right)const result = value |> multiply(2) |> add(1) |> toStringBy default, the piped value is inserted as the first argument. Use _ when you need it in a different position: value |> f(other, _) becomes f(other, value).
Type Checking
Section titled “Type Checking”Run the type checker without generating output:
floe check src/This catches errors like:
- Using
any(useunknowninstead) - Nullable values without
Option<T> - Non-exhaustive pattern matches
- Unused variables and imports