Ask

beginner2 of 8

Learn about ask in fp-ts readertaskeither

Code Editor

02-ask.exercise.ts

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

Test Results

Requirements

describe('ReaderTaskEither ask', () => {
  const env: Env = {
    dbUrl: 'postgresql://localhost:5432',
    apiKey: 'secret-key',
    timeout: 5000,
  }

  it('reads dbUrl from environment', async () => {
    const result = await getDbConnection()(env)()
    expect(E.isRight(result)).toBe(true)
    if (E.isRight(result)) {
      expect(result.right).toBe('postgresql://localhost:5432')
    }
  })

  it('reads timeout from environment', async () => {
    const result = await getTimeout()(env)()
    expect(E.isRight(result)).toBe(true)
    if (E.isRight(result)) {
      expect(result.right).toBe(5000)
    }
  })
})
🧪

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