These
Inclusive-or: represent "this", "that", or "both"
What is These?
These represents three possible states: Left (error), Right (success), or Both (success with warnings). More powerful than Either when you need to return both a result and warnings or metadata. Perfect for validation with warnings.
// Either can't represent warnings: return hasWarnings ? E.left(warnings) : E.right(data) // These can handle both: return TH.both(warnings, data)
Three States
Left, Right, or Both at once
Warnings
Return success with warnings
Accumulation
Collect errors while succeeding
Flexible
More powerful than Either
These in Action
❌ Multiple Return Types
function process(data: Data): Result | Error | Both {
// Complex logic to handle 3 cases
// Type safety is difficult
}
// Awkward to work with✅ These Approach
function process(data: Data): These<Error[], Result> {
return hasWarnings
? TH.both(warnings, result)
: TH.right(result)
}
// Success with warnings supportedPractice Exercises
Basic
Learn about basic in fp-ts these
Fold
Learn about fold in fp-ts these
Map
Learn about map in fp-ts these
From Options
Learn about from options in fp-ts these
Semigroup
Learn about semigroup in fp-ts these
Practical
Learn about practical in fp-ts these
Why Learn These?
Master These
Learn the fundamental concepts and patterns that make These powerful
6 Exercises
Practice with hands-on exercises from advanced level
Production Ready
Apply These patterns to build robust, type-safe applications