Sequencing

advanced7 of 10

Learn about sequencing in fp-ts taskeither

Code Editor

07-sequencing.exercise.ts

💻
Loading editor...
Preparing Monaco Editor with TypeScript support

Test Results

Requirements

describe('TaskEither sequencing', () => {
  it('fetches all successfully', async () => {
    const result = await fetchAll([1, 2, 3])()
    expect(result._tag).toBe('Right')
    if (result._tag === 'Right') {
      expect(result.right).toEqual([10, 20, 30])
    }
  })

  it('fails on first error', async () => {
    const result = await fetchAll([1, 0, 3])()
    expect(result._tag).toBe('Left')
  })

  it('processes in order', async () => {
    const result = await processInOrder([5, 10, 15])()
    expect(result._tag).toBe('Right')
    if (result._tag === 'Right') {
      expect(result.right).toEqual([10, 20, 30])
    }
  })
})
🧪

Ready to Test?

Click "Run Tests" to see how your code performs

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