pigpigyyy / Yuescript

A Moonscript dialect compiles to Lua.
http://yuescript.org
MIT License
423 stars 35 forks source link

Operators as functions, and partial application of operators #125

Open Seirdy opened 1 year ago

Seirdy commented 1 year ago

LiveScript (a descendant of CoffeeScript that also supports features like pipes and spread operators) supports operators as functions, with partial application.

This allows for Polish-like notation:

(in [1 to 3]) 2  # true

It also combines well with pipes:

111 |> (+) 222  # 333

I'd love to see this in Yuescript.

vendethiel commented 1 year ago

(LiveScript's biop are just Haskell's operator sections)

pigpigyyy commented 1 year ago

The in operator is useful to make many comparing expressions simpler, but I'm not getting the use for operator function with partial application, it won't be hard to write functions to generate currying functions, why this should be a builtin feature.