Quickstart

This quickstart shows the core Funkcia flow: model expected failures with Option/Result, then use OptionAsync/ResultAsync for async workflows.

Install

pnpm add funkcia

Import what you need

import { Option, Result } from 'funkcia';
import { OptionAsync } from 'funkcia/option-async';
import { ResultAsync } from 'funkcia/result-async';

Start with Option

Use Option for missing values without throwing.

import { Option } from 'funkcia';

declare function findUserEmail(userId: string): string | null;

const email = Option.fromNullable(findUserEmail('user_123'))
  .filter((value) => value.includes('@'))
  .unwrapOr(() => 'guest@example.com');

Use Result for typed failures

Use Result when you want explicit error payloads.

Move to async with OptionAsync and ResultAsync

Next steps

Last updated

Was this helpful?