monad-examples icon indicating copy to clipboard operation
monad-examples copied to clipboard

Example uses of monads

Example uses of monads

What are monads and why should I care? This repository answers this question by showcasing a selection of examples.

Each example is in a ...-example subfolder. For example the example for software transactional memory (STM) is in stm-example/Main.hs.

See also my related blog post.

Installation

Tested with cabal-install-2.2, GHC 8.2 and GHC 8.4 and Stackage lts-12.13 on Ubuntu 16.04.

Install with cabal

git clone https://github.com/phischu/monad-examples
cd monad-examples
cabal sandbox init
cabal install
cabal configure
cabal build

or with stack

git clone https://github.com/phischu/monad-examples
cd monad-examples
stack install

Featured

The ticked examples are camera-ready. The others are in progress.

  • [x] STM: Software transactional memory for concurrency.
  • [x] (Build) Action: GNU make embedded in Haskell.
  • [x] Pipe: Stream processing.
  • [ ] Process: Distributed programming.
  • [x] Probability: Probability distributions.
  • [x] Scotty: Web server framework.
  • [ ] Relation: SQL embedded in Haskell.
  • [x] ST: Mutable references.
  • [x] Logic: Backtracking search.
  • [x] Spec: Test specification.
  • [x] Parser: Parse binary and textual data.
  • [x] Canvas: Draw on HTML 5 Canvas.
  • [ ] Gen: Generate random inputs.
  • [ ] Suave: Talk with a browser.

Contributions welcome!