Re:Rust, Macros, λ-calculus/Church numerals, oh my
by rbonvall on Saturday June 08, 2019 @09:44AM
(#20132328)
I agree, it's nice to use the same symbols you'd use on paper. I did something similar in Scala http://mez.cl/en/lambda-dsl/
Re:Rust, Macros, λ-calculus/Church numerals, oh my
by nixpulvis on Saturday June 08, 2019 @09:50AM
(#20132357)
Very cool! I think you've inspired me to implement something like `Expression << Expression` much like your `$`.
I'm currently trying to determine the best way to implement `From<Expression> for u64` (or maybe `Option<u64>`...), so I can convert both to and from `u64` types as church encoded numerals. Eventually the goal is to `impl Into/From<Expression>` for all the types one might use, giving a horribly inefficient runtime for Rust ;)
Re:Rust, Macros, λ-calculus/Church numerals, oh my
by nixpulvis on Saturday June 08, 2019 @10:15AM
(#20132493)
P.S. DrRacket (https://racket-lang.org/) let's you insert a `λ` with Ctrl+\.
Again, technically correct... maybe programming languages should match these kinds of quotes too.
But this is all more or less beside the point. I can type `λ!{x.x}` easily, since I have a Greek keyboard on my system (and a λ on my wrist, and a cat named π).
It's even more of a small deal as I've included the equivalent `abs!{x.e}` and `app!(e1,e2)` macros. In fact `λ!` and `γ!` are just macro "aliases".
Also, given the prominence of α-renaming, β-reduction, and η-reduction, I'm very glad I can use these symbols in Rust.