Local
Learn about local in fp-ts readertaskeither
Code Editor
05-local.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('ReaderTaskEither local', () => {
const config: Config = { apiUrl: 'https://api.example.com', timeout: 5000 }
it('gets original config', async () => {
const result = await getConfig()(config)()
expect(E.isRight(result)).toBe(true)
if (E.isRight(result)) {
expect(result.right.timeout).toBe(5000)
}
})
it('overrides timeout locally', async () => {
const result = await withCustomTimeout(getConfig(), 10000)(config)()
expect(E.isRight(result)).toBe(true)
if (E.isRight(result)) {
expect(result.right.timeout).toBe(10000)
expect(result.right.apiUrl).toBe('https://api.example.com')
}
})
it('does not affect original config', async () => {
await withCustomTimeout(getConfig(), 10000)(config)()
const result = await getConfig()(config)()
expect(E.isRight(result)).toBe(true)
if (E.isRight(result)) {
expect(result.right.timeout).toBe(5000)
}
})
})🧪
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