Scala-Inspired Functional Programming for TypeScript
Type-safe, immutable, and composable data structures with unified interfaces
import { Option, Either } from "functype"
// Handle null safety with Option
const user = Option(maybeUser)
.map(u => u.name)
.getOrElse("Guest")
// Elegant error handling with Either
const result = Either
.fromTry(() => JSON.parse(data))
.map(obj => obj.value)
A functional programming library designed for TypeScript developers who value type safety and composition
Familiar constructor functions with method chaining. Works like Scala's collections API.
Do-notation is 12x faster for List comprehensions compared to traditional flatMap chains.
All types implement the same hierarchy of interfaces. Learn once, use everywhere.
Import only what you need. Optimized for minimal bundle size with selective imports.
Safe handling of nullable values with Some and None
Express success/failure with Left and Right values
Immutable arrays with functional operations
Async operations with cancellation and error handling
Scala-like for-comprehensions for monadic composition
Powerful pattern matching and conditional expressions
Explore the foundational types that power functional programming in TypeScript
Safe handling of nullable values with Some and None
Express success/failure with Left and Right values
Immutable arrays with functional operations
Async operations with cancellation and error handling
Scala-like for-comprehensions for monadic composition
Powerful pattern matching and conditional expressions
Get up and running with functype in minutes
npm install functype
Also works with yarn, pnpm, and bun
import { Option, Either, List } from "functype"
// Or use selective imports for smaller bundles
import { Option } from "functype/option"
const result = Option(user)
.map(u => u.email)
.filter(email => email.includes("@"))
.getOrElse("no-email@example.com")
Ready to learn more?