Skip to content

Your First Program

Create a file called hello.fl:

export fn greet(name: string) -> string {
`Hello, ${name}!`
}
greet("world") |> Console.log

Compile it:

Terminal window
floe build hello.fl

This produces hello.ts:

export function greet(name: string): string {
return `Hello, ${name}!`;
}
console.log(greet("world"));

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:

Terminal window
floe build counter.fl

This produces counter.tsx, a standard React component that works with any React setup.

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)
|> toString

By 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).

Run the type checker without generating output:

Terminal window
floe check src/

This catches errors like:

  • Using any (use unknown instead)
  • Nullable values without Option<T>
  • Non-exhaustive pattern matches
  • Unused variables and imports