Skip to main content

Effects for Haskells

Effects in Haskell are how a pure language still reads files, prints output and keeps state. The IO type marks actions that touch the outside world, and they run only from main. Mutable state is modelled with the State monad, IORef or STRef, keeping the impure parts visible in type signatures.

Stage: Abstractions · Part of the Haskell roadmap · Last reviewed 19 November 2026

What to learn in Effects

Effects interview questions

Why does Haskell use the IO type?

IO marks values that describe actions with side effects. A function returning IO String is not a string but a recipe that produces one when run. This keeps pure code free of hidden effects and makes the effectful boundary obvious in types.

What is the difference between the State monad and IORef?

State threads a value through a pure computation, so the function stays referentially transparent and easy to test. IORef is a real mutable cell that lives in IO. Use State when you can, and IORef when you need shared mutable data.

Where Effects fits in the Haskell roadmap

Effects belongs to the Abstractions stage (advanced level). The functional toolkit.

Back to the full Haskell roadmap