Git Product home page Git Product logo

monad-transformers-step-by-step's Introduction

Monad Transformers Step by Step

Haskell source for the paper Monad Transformers Step by Step by Martin Grabmüller, tweaked to work in 2020 and built using Stack.

How this repo is organized

  • Shared data structureds can be found in Lib.hs
  • Each of the eval0 .. eval6 implementations can be found in ./src under a similarly named file.
  • Examples of each eval* function running can be found in the test file.

Changes

I've made the following changes to the example source in order for it to compile with the "latest" Haskell tools (as of May 2020).

Without the MonadFail instance above, you'll get compilation errors like this:

   • No instance for (MonadFail Identity)
        arising from a do statement
        with the failable pattern ‘IntVal i2’
    • In a stmt of a 'do' block: IntVal i2 <- eval2c env e2
      In the expression:
        do IntVal i1 <- eval2c env e1
           IntVal i2 <- eval2c env e2
           return $ IntVal (i1 + i2)
      In an equation for ‘eval2c’:
          eval2c env (Plus e1 e2)
            = do IntVal i1 <- eval2c env e1
                 IntVal i2 <- eval2c env e2
                 return $ IntVal (i1 + i2)
   |
52 |                                  IntVal i2  <- eval2c env e2
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • Control.Monad.Except is used in place of import Control.Monad.Error, as Control.Monad.Error has been deprecated.
    • as the result of this, you'll see ErrorT replaced by ExceptT in most of the examples.

Building

git clone https://github.com/metadave/monad-transformers-step-by-step.git
cd monad-transformers-step-by-step
stack test
 # - or-
stack ghci

Interactive Examples

stack ghci

import qualified Data.Map as Map
eval0 Map.empty exampleExp
-- will display:
IntVal 18

TODO

  • Figure out how to test the eval2* functions

Similar repos

The following repos contain similar implementations, although they don't seem to work in 2020:

monad-transformers-step-by-step's People

Contributors

bookshelfdave avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.