sdiehl / write-you-a-haskell

Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Substitution

NicolasT opened this issue · comments

In the Lambda Calculus chapter, under Substitution, there's first an explanation that in ((\x.e)a) x is replaced by a in e, also written as [x/a]e.
This is immediately followed by (\a.e)x -> [x/a]e which seems like the reverse of what's above to me.

Assuming the second notation is correct (so [x/a]e means 'occurrences of a in e are substituted by x', or ((\a.e)x)), the next example seems not to be in line: [y/x](\y.yx) would be 'occurrences of x in (\y.yx) are substituted by y, or (\y.yy), unlike the text which says (\x.xx), which is equivalent but could be confusing.

Overall: it might be just me but I believe there might be some inconsistencies in those paragraphs. I'd love to send a PR to fix, but I don't know what the proper fix would be.

Sorry about the ambiguity. The notation I intend to use is:

[substitution/replacement] body

So under beta reduction

(\x.e)a

a is bound to the name x in e by the step:

(\x.e)a -> [x/a]e

Which I think I had permuted in the example.

Let me know if it's clearer now.

I'm somehow unable to rebuild and check:

./includes < lambda_calculus.md | pandoc -c css/style.css --template page.tmpl -s -f markdown -t html --standalone --toc --toc-depth=2 --mathjax --highlight-style pygments -o lambda_calculus.html
pandoc: Text.Regex.PCRE.Light: Error in regex: missing opening brace after \o

Note: I had this with other pages before as well.

Curious, I don't know how changing "x" to "a" could cause a pandoc error.

Is it an encoding issue, the files are supposed to be in in utf-8?

Never mind, my bad. I installed pandoc in a sandbox to build includes, but when running make, it uses system-pandoc (which is another version). Setting PATH to the sandbox bin seems to solve the error above.

Anyway, LGTM now!

Yeah, I probably should just cabalize the whole project, and just make the Makefile into a Haskell script.