Task
Lazy async computations that always succeed
What is Task?
Task represents a lazy asynchronous computation that always succeeds. Unlike Promise which executes immediately, Task only runs when you explicitly call it. This gives you control over when effects happen and makes testing easier.
// Promise executes immediately:
const data = fetch('/api') // already running!
// Task is lazy:
const data = T.of(() => fetch('/api'))
data() // runs nowLazy Async
Deferred async computations
Always Succeeds
No error handling needed
Composable
Chain and combine async work
Parallel Ready
Run multiple tasks concurrently
Task in Action
❌ Eager Promises
const fetchData = fetch('/api/data')
// Executes immediately
// Can't control when it runs
// Hard to test✅ Task Approach
const fetchData = T.of(() => fetch('/api/data'))
// Lazy evaluation
// Controlled execution
const result = fetchData() // Run when neededPractice Exercises
Basic
Learn about basic in fp-ts task
Map
Learn about map in fp-ts task
Chain
Learn about chain in fp-ts task
Parallel
Learn about parallel in fp-ts task
Delay
Learn about delay in fp-ts task
Practical
Learn about practical in fp-ts task
Why Learn Task?
Master Task
Learn the fundamental concepts and patterns that make Task powerful
6 Exercises
Practice with hands-on exercises from intermediate level
Production Ready
Apply Task patterns to build robust, type-safe applications