With Either
Learn about with either in fp-ts pipe
Code Editor
03-with-either.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('getUserEmail', () => {
it('returns Right with email when user found', () => {
const result = getUserEmail(1)
expect(result).toEqual({ _tag: 'Right', right: 'alice@example.com' })
})
it('returns Left for invalid ID', () => {
const result = getUserEmail(0)
expect(result).toEqual({ _tag: 'Left', left: 'Invalid ID' })
})
it('returns Left when user not found', () => {
const result = getUserEmail(99)
expect(result).toEqual({ _tag: 'Left', left: 'User not found' })
})
})🧪
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