Luarrow – True pipeline operators and elegant Haskell-style function compositio

Posted by todsacerdoti 9 days ago

Counter24Comment4OpenOriginal

Comments

Comment by orthoxerox 3 days ago

I love it when people push syntax to its limits. The only thing I do not like is how `^` points in the wrong direction when you stack it vertically, like in the example:

    local _ = 5
      % arrow(function(x) return -x end)
      ^ arrow(function(x) return x + 10 end)
      ^ arrow(function(x) return x * x end)
      ^ arrow(print)  -- 25

Comment by psychoslave 3 days ago

Yeah but actually it’s really a keyword artefact in that case. It’s more surprising that with all the emphases in the doc about readability, it will stick to an identifier like "arrow", when "which", "that" or "through" would make it far approachable. At least I would guess so.

  -- what we don’t care to use later, we brush under the mat/rug [2,3]
  local mat = 5
      -- nub, as the essence or core of an issue, argument etc. [1]
      % through(function(nub) return -nub end)
      ^ through(function(nub) return nub + 10 end)
      ^ through(function(nub) return nub * nub end)
      ^ through(print)  -- 25


[1] https://en.wiktionary.org/wiki/nub

[2] https://dictionary.cambridge.org/dictionary/english/sweep-un...

[3] https://idioms.thefreedictionary.com/brush+(something)+under...

Comment by NuclearPM 3 days ago

Lua really needs shorter function syntax for this type of thing to work.

My hobby compile to Lua language uses [ x | x + 1 ] and [ ] for a no-arg function/block.

Comment by wosined 3 days ago

Just use Haskell. You can be among the first.