Effect.ts: Absence as First-Class
Philosophy • Lesson 46 of 51
46. The Mental Model Shift
Stop thinking "async". Start thinking "absent".
Code Example
// OLD MENTAL MODEL: "Async/Await"
// "This operation takes time"
async function getUser() {
const data = await fetchUser();
return data;
}
// NEW MENTAL MODEL: "Absence Resolution"
// "This data doesn't exist yet, here's how to get it"
const getUser = Effect.gen(function* () {
const data = yield* fetchUser;
// ^^^^^^
// Resolving absence
return data;
});
// The shift:
// await = "wait for async"
// yield* = "resolve this absence"
Interactive Example
const output: string[] = [];
output.push(' Mental model shift:');
output.push('');
output.push('BEFORE:');
output.push(' "This operation is async"');
output.push(' → Focus on TIME');
output.push('');
output.push('AFTER:');
output.push(' "This data doesn't exist yet"');
output.push(' → Focus on ABSENCE');
output.push('');
output.push('Async ≠ slow');
output.push('Async = absent data');
output.push('');
output.push(' Type the absence!');
return output.join('
');
Explanation
The paradigm shift in one diagram:
TRADITIONAL THINKING:
"Async" → Time delay → Await → Value
ABSENCE-FIRST THINKING:
"Value doesn't exist" → Description of HOW → Execute → Value
Key insights:
- Async isn't about TIME, it's about ABSENCE
- await isn't waiting, it's RESOLVING
- Promises aren't delayed values, they're ABSENT values
- Effect makes the absence explicit and typed
Stop thinking:
- "This is slow" → "This is absent"
- "This takes time" → "This doesn't exist yet"
- "This is async" → "This requires resolution"
Absence-first thinking: it changes everything!
Part 46 of 51 in the Effect.ts Absence Modeling series
←
→