HackSoc/NYHC — pull request #6 by Barrucadu (2014-06-16 13:53:33+00:00)
Title: Basic lambda-lifter

Behold, the first version of a lambda-lifter! Now we have, modulo a runtime, a Turing-complete language! There are some flaws:

- It doesn't work for `if` expressions
- it introduces redundant local definitions
- It does not preserve full laziness
- It throws errors
- It's defined entirely in `NYHC.IR.Core`, rather than `NYHC.IR.Unlambda`, which seems a bit odd.

The last point could have been directly addressed, but the convention I introduced with the `Core -> GCore` pass is to have a `from*` function in the target module. I now think this is a bad idea. So, to fix these issues, here is what I propose to do in three future pull requests:

- PR 1:
- Refactor `fromUnlambda` and `fromCore` to `toCore` and `toGCode`, and also tidy up code in general
- Introduce a compiler monad to act as a source of globally unique names, and handle error reporting
- PR 2:
- Add another desugaring pass to convert `if`s into `case`s, and remove `if` from the Unlambda and Core ASTs
- PR 3:
- Improve the lambda lifter by removing redundant local definitions
- Preserve laziness where possible