Functional Helpers
Functional helpers provide small, composable building blocks for structuring logic as clear, predictable pipelines. They never mutate input, never throw exceptions, and always make control flow explicit. Functional helpers allow you to express transformations, observations, conditional logic, and safe fallbacks without relying on imperative branching or try/catch.
They are pure, intention‑revealing tools designed to make your normalization, validation, and parsing flows easier to read, easier to test, and easier to reason about.
Functional helpers in Jane are predictable, side‑effect‑free (except where explicitly allowed), and designed to compose cleanly with every other part of the system.
Available Functional Helpers
Functional helpers are grouped by the kind of behavior they enable:
Pipelines
Observation
tap: Observe a value inside a pipeline without modifying it.
Conditional application
maybe: Apply a function only when the value is not null or undefined.
Safe execution
tryOrDefault: Execute a function and fall back to a default value on error.
Each helper is small, focused, and designed to be combined with others to build expressive, defensive, and maintainable flows.
When to Use Functional Helpers
Use functional helpers when:
- You want to express logic as a sequence of pure transformations rather than imperative steps.
- You want to avoid try/catch and instead rely on predictable, structured error handling.
- You need to observe or log values inside a pipeline without modifying them.
- You want to conditionally apply transformations only when a value exists.
- You want to build reusable, composable building blocks for normalization, validation, or parsing.
Functional helpers help you write code that is easier to test, easier to reason about, and easier to maintain. They eliminate hidden control flow, implicit mutation, and exception‑driven logic.
Why Functional Helpers Matter
Functional helpers form the connective issue of Jane’s runtime model: type guards → normalizers → functional helpers → validators → parsers:
- Type guards tell you what a value is.
- Normalizers tell you what shape it should be.
- Functional helpers structure the logic that connects these steps.
- Validators tell you whether it’s acceptable.
- Parsers combine everything into a typed result.
Functional helpers make your pipelines explicit, predictable, and safe. They remove the need for ad‑hoc branching, scattered try/catch blocks, and mutation‑driven logic. They help you build systems where every step is intentional, documented, and easy to follow.