Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Haskell to MIT 6.005 FP pseudocode pretty-printer

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 MIT6005.hs
Octocat-spinner-32 README
Octocat-spinner-32 transform.hs
README
HASKELL TO MIT 6.005 FP PSEUDOCODE TRANSFORMER
    hacked up by Edward Z. Yang

Hat-tip to the HughesPJ pretty-printer combinators and the original
implementation of the pretty-printer in Language.Haskell.Pretty.

Usage is very simple:

    runghc transform.hs FILENAME.hs

You will need to do some post-processing:

    * Adding types to all arguments (since that's what they want)
        (TODO: I bet we could build this in using f (a :: Int) = ...)
    * Giving all data structure fields names
    * Add comments (the parser doesn't build syntax for them, so we
      can't give them back to you.)

Known bugs:

    * Doesn't handle the pattern x:y:xs correctly, so you need to
      hint the right fixness with x:(y:xs)
    * Doesn't handle type signatures for higher order functions
      correctly

Doesn't support translating all syntax, known differences include:

    * At-bindings, e.g. a@(Constructor x y)
    * Let...In...
    * Case...Of...
        For these three, you can probably get away by telling course
        staff what you mean.
    * Lambda functions
        Separate this out to a helper function.
    * Currying
        Just don't.  Currying is hard to understand to the uninitiated.
    * Record syntax
        Haskell relies on positional arguments for simple
        data-structures; 6.005 wants you to be explicit.  In theory
        record syntax gets you this, in practice you don't actually want
        to muck up your Haskell code.  Fix this manually.
    * Do-notation
        Just don't use monads.
    * User defined infix operators
        Just don't.

This loses data (that the 6.005 staff doesn't care about), in
particular:

    * Module information
    * Imports

I recommend turning off the implicit Prelude (by doing an
``import Prelude ()``) and then importing functions as necessary.
The 6.005 course staff might get mad at you if you use too much
Prelude goodness.
Something went wrong with that request. Please try again.