alpaca-lang / alpaca

Functional programming inspired by ML for the Erlang VM
Other
1.44k stars 47 forks source link

Auto-imported pipe operator #232

Open lpil opened 6 years ago

lpil commented 6 years ago

Hello!

I'd like to suggest adding an automatically imported pipe-forward function to Alpaca.

let value |> func =
  func value 

This would allow us to chain functions to avoid some unneeded variables while still writing in an easy-to-read left-to-right/top-to-bottom style. :)

"123"
|> string.chars
|> list.reverse
|> string.join "-"
-- "3-2-1"
j14159 commented 6 years ago

IIRC @lepoetemaudit has implemented this somewhere as a proof of concept. Might fit in with @Licenser's ideas in #184, whatever form that takes?

Licenser commented 6 years ago

<3 I'm still in love with the idea if implementing part of alpaca in alpaca it feels so elegant and easy to reason about :D