A brief exploration of the various approaches to modeling side effects in a purely functional programming language.
Write a program that initializes an accumulator and random seed both with
0 and then runs the following procedure 10 times:
- Log the value of the accumulator.
- Pick an integer uniformly randomly from the half-open interval
- Mutate the accumulator by adding the random integer to it.
Thus, 3 computational effects are exhibited: logging, randomness, and mutable state.
This repository contains 4 implementations of the program described above, each demonstrating a specific technique:
- A bespoke monad
- A standard monad transformer stack
- A free monad
Effmonad from the "extensible effects" framework
- A Registry using the