/haskell-testing-stubbing-io

Some examples of how one might test an IO-heavy Haskell application

Primary LanguageHaskell

Testing IO-Heavy Haskell Applications

The code in this repository's purpose is to demonstrate how one might test an IO-heavy Haskell application w/out resorting to side-effectful operations.

This project was inspired by Sean Shubin's hello.

Program Description

The program must do the following:

  • take a command-line argument specifying the name of a file
  • use that argument to read the contents of said file off disk
  • prepend the string "hello " to the contents of the file
  • print the aforementioned greeting (i.e. "hello martha") to the console
  • print the number of milliseconds it took to complete steps 1-4 to the console

Required Tooling

All examples rely on Stack by FP Complete. On a Mac, one can install Stack using Homebrew:

brew update
brew install haskell-stack

To build, install, and run the examples, look for run.sh and test.sh in the root of each example-folder.

Examples

References