Lab 05: FP Architecture
Overview
Step 1: Why fp-ts?
fp-ts principles:
✓ Errors as values (not exceptions)
✓ Pure functions (no side effects)
✓ Composability via pipe()
✓ Type-safe at every level
✓ Lazy evaluation (Task vs Promise)
Core types:
Option<A> — value that may not exist (replaces null)
Either<E, A> — right is success, left is error
Task<A> — lazy async (never rejects)
TaskEither<E, A> — async + typed errors
Reader<R, A> — computation that needs environment R
ReaderTaskEither<R, E, A> — all three combinedStep 2: Option — Safe Null Handling
Step 3: Either — Typed Errors
Step 4: TaskEither — Async + Typed Errors
Step 5: Reader — Dependency Injection
Step 6: ReaderTaskEither — Full Composition
Step 7: Do-Notation with bind/bindW
Step 8: Capstone — TaskEither Pipeline
Summary
Type
Purpose
Compose With
Last updated
