Allow binary operators to be used as lambdas (#385)

* Add operator lambdas

* Do not register anonymous functions as called functions

* Add tests

* Update CHANGELOG

* Update the docs

* Do not allow (..) to be used as a lambda

* Rename the function sum to any
This commit is contained in:
Gaith Hallak
2022-06-03 13:12:23 +04:00
committed by GitHub
parent b0e6418161
commit b3767071a8
6 changed files with 46 additions and 2 deletions
+5
View File
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
```
[1, 2, 3] |> List.first |> Option.is_some // Option.is_some(List.first([1, 2, 3]))
```
- Allow binary operators to be used as lambdas
```
function sum(l : list(int)) : int = foldl((+), 0, l)
function logical_and(x, y) = (&&)(x, y)
```
### Changed
- Error messages have been restructured (less newlines) to provide more unified errors. Also `pp_oneline/1` has been added.
- Ban empty record definitions (e.g. `record r = {}` would give an error).