3 ms·
I've been prototyping a programming language[0] with Haskell-like function conventions (all functions are unary and the "primary" parameter comes last). I recen
by matt_kantor 2y ago
I've been prototyping a programming language[0] with Haskell-like function conventions (all functions are unary and the "primary" parameter comes last). I recently added syntax to allow applying any "binary" function using infix notation, with `a f b` being the same as `f(b)(a)`[1]. Argument order is swapped compared to Haskell's infix notation (where `a f b` would desugar to `f(a)(b)`).
Along with the `|>` operator (which is itself just a function that's conventionally infixed), this turns out to be really nice for flexibility/reusability. All of these programs do the same thing:
1 - 2 - 3 + 4
1
|> -(2)
|> -(3)
|> +(4)
+(4)(
-(3)(
-(2)(1)
)
)
It was extremely satisfying to discover that with this encoding, `|>` is simply an identity function!
[0]: https://github.com/mkantor/please-lang-prototype https://github.com/mkantor/please-lang-prototype
[1]: In reality variable dereferencing uses a sigil, but I'm omitting it from this comment to keep the examples focused.