Fold
Learn about fold in fp-ts taskeither
Code Editor
05-fold.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('TaskEither fold operations', () => {
it('matches success case', async () => {
const task = TE.right(42)
const result = await getMessage(task)
expect(result).toBe('Success: 42')
})
it('matches error case', async () => {
const task = TE.left('failed')
const result = await getMessage(task)
expect(result).toBe('Error: failed')
})
it('gets success value', async () => {
const task = TE.right(100)
const result = await getWithDefault(task)
expect(result).toBe(100)
})
it('gets default on error', async () => {
const task = TE.left('error')
const result = await getWithDefault(task)
expect(result).toBe(0)
})
})🧪
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