Effect.ts: Absence as First-Class

PhilosophyLesson 25 of 51

25. The Aha Moment - Absence Everywhere

Once you see it, you can't unsee it. Every async operation is about ABSENT VALUES.

Code Example
// Database query:
// "The data isn't here. It's in the database."
const user = yield* db.query("...");

// API call:
// "The data isn't here. It's on a server."
const response = yield* fetch("...");

// File read:
// "The data isn't here. It's on disk."
const contents = yield* readFile("...");

// User input:
// "The data isn't here. User hasn't typed it yet."
const input = yield* getInput();

// Time-based:
// "The data isn't here. It doesn't exist until 2pm."
yield* Effect.sleep("until 2pm");

// ALL of these model ABSENCE!
Interactive Example
const output: string[] = [];
output.push(' The paradigm shift:');
output.push('');
output.push('Database query: Data is absent (on server)');
output.push('API call: Data is absent (in network)');
output.push('File read: Data is absent (on disk)');
output.push('User input: Data is absent (not typed yet)');
output.push('setTimeout: Data is absent (in future)');
output.push('');
output.push('Everything is ABSENCE!');
output.push('');
output.push('Effect types:');
output.push('  • WHAT is absent');
output.push('  • HOW it can fail');
output.push('  • WHAT is needed');
output.push('');
output.push(' Absence is first-class!');
return output.join('
');
Explanation

The paradigm shift: everything is absence.

Before Effect: "Async operations take time, so we await them"

After Effect: "Data is ABSENT. We type the absence and describe HOW to resolve it."

Once you see it:

  • Async = resolving absent data over time
  • Dependencies = absent services we require
  • Errors = ways absence fails to resolve
  • Retry/timeout = HOWs for resolving flaky absence
  • Streams = sequential absence
  • Fibers = concurrent absence resolution

Absence isn't a problem to hide - it's the MODEL! Effect makes absence first-class, typed, and composable.


Part 25 of 51 in the Effect.ts Absence Modeling series