mirror of
https://github.com/anoma/juvix.git
synced 2024-12-02 10:47:32 +03:00
e9284b3ef6
* Closes #1992 A function identifier `fun` can be declared as an iterator with ``` syntax iterator fun; ``` For example: ```haskell syntax iterator for; for : {A B : Type} -> (A -> B -> A) -> A -> List B -> List A; for f acc nil := acc; for f acc (x :: xs) := for (f acc x) xs; ``` Iterator application syntax allows for a finite number of initializers `acc := a` followed by a finite number of ranges `x in xs`. For example: ``` for (acc := 0) (x in lst) acc + x ``` The number of initializers plus the number of ranges must be non-zero. An iterator application ``` fun (acc1 := a1; ..; accn := an) (x1 in b1; ..; xk in bk) body ``` gets desugared to ``` fun \{acc1 .. accn x1 .. xk := body} a1 .. an b1 .. bk ``` The `acc1`, ..., `accn`, `x1`, ..., `xk` can be patterns. The desugaring works on a purely syntactic level. Without further restrictions, it is not checked if the number of initializers/ranges matches the type of the identifier. The restrictions on the number of initializers/ranges can be specified in iterator declaration: ``` syntax iterator fun {init: n, range: k}; syntax iterator for {init: 1, range: 1}; syntax iterator map {init: 0, range: 1}; ``` The attributes (`init`, `range`) in between braces are parsed as YAML to avoid inventing and parsing a new attribute language. Both attributes are optional. |
||
---|---|---|
.. | ||
230 | ||
258 | ||
265 | ||
BindGroupConflict | ||
Dependencies | ||
ImportCycle | ||
Internal | ||
issue1337 | ||
issue1344 | ||
issue1700 | ||
NoDependencies | ||
StdlibConflict | ||
Termination | ||
UsingHiding | ||
AmbiguousConstructor.juvix | ||
AmbiguousExport.juvix | ||
AmbiguousModule.juvix | ||
AmbiguousSymbol.juvix | ||
AppLeftImplicit.juvix | ||
AsPatternAlias.juvix | ||
ConstructorExpectedLeftApplication.juvix | ||
DanglingJudoc.juvix | ||
DuplicateClause.juvix | ||
DuplicateFixity.juvix | ||
DuplicateInductiveParameterName.juvix | ||
ImplicitPatternLeftApplication.juvix | ||
InfixError.juvix | ||
InfixErrorP.juvix | ||
Iterators1.juvix | ||
Iterators2.juvix | ||
Iterators3.juvix | ||
Iterators4.juvix | ||
Iterators5.juvix | ||
juvix.yaml | ||
LacksFunctionClause.juvix | ||
LacksTypeSig2.juvix | ||
LacksTypeSig.juvix | ||
LetMissingClause.juvix | ||
ModuleNotInScope.juvix | ||
MultipleDeclarations.juvix | ||
MultipleExportConflict.juvix | ||
NestedAsPatterns.juvix | ||
NestedPatternBraces.juvix | ||
NotInScope.juvix | ||
PragmasFormat.juvix | ||
PragmasYAML.juvix | ||
QualSymNotInScope.juvix | ||
Tab.juvix | ||
UnusedOperatorDef.juvix | ||
WrongModuleName.juvix |