ethereum / moon-lang

Minimal code-interchange format
MIT License
193 stars 20 forks source link

Use `_` as a syntactic sugar for lambda. #34

Open Kesanov opened 7 years ago

Kesanov commented 7 years ago

It just seems too handy not to have it.

1. Right now.

(add _ _) == add

foo =
  (( flatMap _ [1, 2]) a =>
  (( flatMap _ [3, 4]) b =>
   ( wrap [a,b]) ))

bar = 
 (( map2 _ [1,3,5] [2,4,6]) a => b =>
    (doSomething
      ...
      ... ))

2. With mathematical parentheses.

foo =
  (flatMap _ [1, 2]) a =>
  (flatMap _ [3, 4]) b =>
   wrap [a,b]

bar = 
  (map2 _ [1,3,5] [2,4,6]) a => b =>
    doSomething
      ...
      ...

3. With infix operators.

foo =
  flatMap _ [1, 2] | a =>
  flatMap _ [3, 4] | b =>
  wrap [a,b]

bar = 
  map2 _ [1,3,5] [2,4,6] | a => b =>
    doSomething
      ...
      ...
VictorTaelin commented 7 years ago

Looks very cool, just need time to test it (as we don't have tests).