/free-monads

Code for Gabriel Gonzalez's fantastic write up on free monads

Primary LanguageHaskellOtherNOASSERTION

Build Status

free-monads

Code inspired by Gabriel Gonzalez's fantastic article on free monads

Setup

Requirements

  • Docker or Stack

Building

Stack

make

Docker

make docker

Examples

Run stack ghci to play with the example programs and interpreter:

interpreter0 = putStrLn (showProgram program6)
  where
    subroutine2 :: Subroutine
    subroutine2 = output 'A'

    program6 :: Program
    program6 = do
        subroutine2
        bell
        done
λ > interpreter0
output 'A'
bell
done
interpreter1 = putStrLn (showProgram program7)
  where
    program7 :: Program
    program7 = do
      output 'A'
      output 'B'
      output 'C'
      bell
λ > interpreter1
output 'A'
output 'B'
output 'C'
bell
done