functional-programming

mcclowes's avatarfrom mcclowes

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

⭐3stars🔀0forks📁View on GitHub🕐Updated Jan 1, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill provides comprehensive guidance on functional programming (FP) best practices specifically tailored for the Lea programming language. It helps developers write cleaner, more maintainable code by enforcing core principles like immutability, pure functions, and function composition, while navigating Lea-specific syntax nuances such as pipeline operators and unique async handling.

Use Cases

  • Case 1: Developing robust and side-effect-free logic in Lea by implementing pure functions and immutable data structures.
  • Case 2: Refactoring complex imperative code into readable, left-to-right data transformation pipelines using Lea's specific pipe (/>) syntax.
  • Case 3: Ensuring code reliability by applying Lea-specific warnings, such as avoiding traditional currying and correctly using the #async decorator instead of monads.
  • Case 4: Optimizing code quality through strict type enforcement and higher-order function patterns to build scalable software architectures.
namefunctional-programming
# IMPORTANTKeep description on ONE line for Claude Code compatibility
descriptionUse when writing functional code - covers FP best practices (Lea differs from traditional FP languages)

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)