Restrictionmodules-value-recursion
An occurrence of a variable in an expression is delayed if it lies within a lambda expression in , and direct otherwise. For a value declaration of a , say that if contains a binding and is bound by and has a direct occurrence in . No value declaration of a may have a cycle . This takes the place, for the value declarations of a , of the restriction on recursive groups of Section 2.10. Since a binding with parameters is a derived form whose equivalent form is a lambda expression (Appendix A), every occurrence in its body is delayed, and a rejected cycle passes only through values without parameters. A delayed occurrence used during the evaluation of the very value it refers to passes this restriction; no evaluation rule applies to it (Chapter 7).
Tests (5)
- elm / CovLambdaBoundaryCaseBoundaryInARecursiveValueTestA top-level function defined as a lambda whose `case` returns a different lambda per branch, one of which calls the function recursively.
- elm / CyclicDefinitionATopLevelValueDefinedByItselfTestA top-level value defined in terms of itself is rejected with a CYCLIC DEFINITION error.
- elm / PureMutualRecursiveValueTestTwo top-level values that refer to each other through lambdas can be defined and used.
- elm / PureRecursiveValueThunkTestA top-level value that refers to itself inside a lambda can be defined and used.
- elm / RecursiveTopLevelLambdaTestA top-level value defined as a lambda that refers to itself can be called recursively.
In Lean
This restriction is decided on the syntax tree, as the book states it, by Src.ValueRecursion (StandardElmMech/Src/Restrictions.lean, line 316), whose decider the kernel runs; each written test program has a theorem that it meets the restrictions, or that it breaks this one. Broken by: CyclicDefinitionATopLevelValueDefinedByItselfTest, QualifiedTypeNotExposedTest.
Discussions
Discuss this restriction·Search the discussions on GitHub
Discussions are on GitHub; one about this restriction has [res:modules-value-recursion] in its title.
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.