Haskell to MIT 6.005 FP pseudocode pretty-printer
Fetching latest commit…
Cannot retrieve the latest commit at this time
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.