How can I use the State monad, or the StateT monad transformer, to mimic the IO monad for testing functions that run in a IO-based monadic stack?
Using State as an alternative to IO in testing Take a simple function like this foo :: IO () foo = putStrLn “ciao” This is not testable, because it affects the state of the terminal, which I can’t write a test for. Using the approach suggested here, one can rewrite the above in terms of […]