stepchowfun/effects

A brief exploration of the various approaches to modeling side effects in a purely functional programming language.

Haskell

97

87 commits

updated Jan 17, 2022

See the code

README

Effects

A brief exploration of the various approaches to modeling side effects in a purely functional programming language.

Build status

The challenge

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 [0, 10).
  • Mutate the accumulator by adding the random integer to it.

Thus, 3 computational effects are exhibited: logging, randomness, and mutable state.

Techniques demonstrated

This repository contains 4 implementations of the program described above, each demonstrating a specific technique:

Instructions

Make sure you have Toast installed. Then you can run toast run to build and run the demo.

computational-effects
functional-programming
haskell

Contributors

stepchowfun

85 commits

StevenXL

1 commits

stepchowfun/effects

A brief exploration of the various approaches to modeling side effects in a purely functional programming language.

Haskell

97

87 commits

updated Jan 17, 2022

See the code

README

Effects

A brief exploration of the various approaches to modeling side effects in a purely functional programming language.

Build status

The challenge

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 [0, 10).
  • Mutate the accumulator by adding the random integer to it.

Thus, 3 computational effects are exhibited: logging, randomness, and mutable state.

Techniques demonstrated

This repository contains 4 implementations of the program described above, each demonstrating a specific technique:

Instructions

Make sure you have Toast installed. Then you can run toast run to build and run the demo.

computational-effects
functional-programming
haskell

Contributors

stepchowfun

85 commits

StevenXL

1 commits

Languages

Haskell

87.6%

Ruby

12.4%