Create Reader

beginner1 of 8

Learn about create reader in fp-ts reader

Code Editor

01-create-reader.exercise.ts

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

Test Results

Requirements

describe('Reader basics', () => {
  const config: Config = {
    apiUrl: 'https://api.example.com',
    timeout: 5000,
  }

  it('getApiUrl extracts apiUrl from config', () => {
    const result = getApiUrl()(config)
    expect(result).toBe('https://api.example.com')
  })

  it('getTimeout extracts timeout from config', () => {
    const result = getTimeout()(config)
    expect(result).toBe(5000)
  })

  it('Reader can be called with different configs', () => {
    const testConfig: Config = { apiUrl: 'https://test.com', timeout: 1000 }
    expect(getApiUrl()(testConfig)).toBe('https://test.com')
    expect(getTimeout()(testConfig)).toBe(1000)
  })
})
🧪

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