mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 05:42:26 +03:00
c143259aee
* Closes #3039 * Closes #3043 * Closes #2970 * Closes #3089 * Parser allows trailing semicolons for any kind of semicolon-separated items: - let-block statements, - module statements, - record declaration statements, - record update fields, - record pattern fields, - named application arguments, - list literal items, - list pattern items, - open statement using/hiding items, - `syntax iterator` declaration parameters, - `syntax fixity` declaration parameters. * Formatter prints trailing semicolons if the items are displayed on separate lines, removes them if on a single line. * The formatting of multiline lists is changed to make it consistent with other semicolon-separated blocks: ``` [ 1; 2; 3; ] ``` instead of ``` [ 1 ; 2 ; 3 ] ```
26 lines
520 B
Plaintext
26 lines
520 B
Plaintext
module RecordIterator;
|
|
|
|
trait
|
|
type Foldable (container elem : Type) :=
|
|
mkFoldable@{
|
|
syntax iterator for {init := 1; range := 1};
|
|
for : {B : Type} -> (B -> elem -> B) -> B -> container -> B;
|
|
|
|
syntax iterator rfor {init := 1; range := 1};
|
|
rfor : {B : Type} -> (B -> elem -> B) -> B → container → B;
|
|
};
|
|
|
|
open Foldable;
|
|
|
|
foldl
|
|
{container elem}
|
|
{{Foldable container elem}}
|
|
{B : Type}
|
|
(g : B -> elem -> B)
|
|
(ini : B)
|
|
(ls : container)
|
|
: B :=
|
|
for (acc := ini) (x in ls) {
|
|
g acc x
|
|
};
|