Open denismerigoux opened 1 month ago
One possible syntax:
Since we already have <foo(v)> for <v> among <list>
for map
one possibility would be to extend that with details: <foo(v,acc)> for <v> among <list> accumulating into <acc> starting from <init>
(the starting
could be removed for conciseness... maybe the into
(or even the accumulating
?) as well ?)
E.g. Compute the sum of a list of money with:
x + y for x among revenues accumulating into y starting from $0
Right now, many of our syntactic list manipulation operators are implemented underneath using
fold
. However, the user cannot directly write afold
in the Catala surface syntax. The CNAF expressed the need for such an operator to be exposed. As it is polymorphic, it will require special syntax.The signature for this operator would be
fold : 'a list -> ('b -> 'a -> 'b) -> 'b -> 'b
.