Parallel
Learn about parallel in fp-ts taskeither
Code Editor
08-parallel.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('TaskEither parallel execution', () => {
it('fetches all in parallel', async () => {
const start = Date.now()
const result = await fetchAllParallel([1, 2, 3])()
const duration = Date.now() - start
expect(result._tag).toBe('Right')
if (result._tag === 'Right') {
expect(result.right).toEqual([10, 20, 30])
}
// Should be faster than sequential (< 25ms vs 30ms)
expect(duration).toBeLessThan(25)
})
it('combines parallel results', async () => {
const task1 = TE.right(10)
const task2 = TE.right(20)
const task3 = TE.right(30)
const result = await combineResults(task1, task2, task3)()
expect(result._tag).toBe('Right')
if (result._tag === 'Right') {
expect(result.right).toBe(60)
}
})
})🧪
Ready to Test?
Click "Run Tests" to see how your code performs
Quick Tips
•Read the TODO comments in the code
•Use Reset to restore original code
•Check Solution if stuck
Pro Tips
💡 Stuck? Here's what to try:
- • Read the comments in the code carefully
- • Run tests frequently to get feedback
- • Check the fp-ts documentation
- • Use the solution if you need help
🚀 Learning Approach:
- • Focus on understanding, not just solving
- • Experiment with different approaches
- • Think about real-world applications
- • Build on previous exercises