# Functional Programming

> Use when writing functional code - covers FP best practices (Lea differs from traditional FP languages)

- Skill: `tomevault-io/functional-programming` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/functional-programming`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/functional-programming/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/functional-programming

---


# Functional Programming Best Practices

## Quick Start

```
-- Prefer pure functions and immutable data
let double = (x) -> x * 2
[1, 2, 3] /> map(double) /> filter((x) -> x > 2)
```

## Core Principles

- **Immutability**: Use `let` by default, `maybe` only when mutation is necessary
- **Pure functions**: No side effects, same input always produces same output
- **Composition**: Build complex behavior from simple, composable functions
- **Higher-order functions**: Pass functions as arguments, return functions

## Lea-Specific Warnings

**Lea differs from traditional FP languages:**

- **No currying** - Use placeholders: `5 /> add(3, input)`
- **Pipes prepend** - `x /> fn(a)` becomes `fn(x, a)`
- **Mutable bindings** - `maybe` allows mutation; avoid unless necessary
- **No monads** - Async uses `#async` decorator instead
- **Opt-in types** - Add `:: Type :> ReturnType`, use `#strict` for enforcement

## Notes

- Prefer `let` over `maybe`
- Use pipelines (`/>`) for left-to-right data flow
- Callbacks receive `(element, index)`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/mcclowes) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

