Elm Exactly

Rule 91d-dec-rec

DeclarationsE⊢dec⇒VE\jdg{E}{\dec}{\VE}
E⊢valbind⇒VEDom VE∩FV(valbind)≠∅E⊢valbind⇒Rec VE\frac{\begin{array}{c}\jdg{E}{\valbind}{\VE}\premsep\Dom\VE\cap\dcoreFV(\valbind)\neq\emptyset\end{array}}{\begin{array}{c}\jdg{E}{\valbind}{\Rec\VE}\end{array}}
(91)
Read it in its chapter·Permanent address: /standard/rules/d-dec-rec

Referred to from

TeX source
\defnrule[r:d-dec-rec]
  {\jdg{E}{\valbind}{\VE}\premsep\Dom\VE\cap\dcoreFV(\valbind)\neq\emptyset}
  {\jdg{E}{\valbind}{\Rec\VE}}

Tests (23)

  • elm / AccessorFunctionFieldTailCallTest
    Record accessors for function-typed fields can be passed as arguments of self-recursive tail calls.
  • elm / AccessorPlaceholderAccessorOfAFunctionFieldPassedInTailCallsTest
    Record accessors for function-typed fields can be passed as arguments of tail calls, at top level and in an unannotated let-bound function.
  • elm / AnnotatedLetRecFnResultTest
    A recursive let-bound function whose type annotation has a function as its result works.
  • elm / CharCaptureEscapedTailDefTest
    A tail-recursive local function that refers to a `Char` argument of its enclosing function still works when it is returned inside a list and called later.
  • elm / CompilerIssue1766LetMutualRecursionMismatchTest
    Mutually recursive let functions give a type a false "mismatch" with itself.
  • elm / LetMutualRecursionBetweenLocalsTest
    Two functions defined in the same `let` call each other.
  • elm / LetRecClosureTest
    A recursive function defined in a `let` block captures a parameter of the enclosing function and is used by an earlier binding of the same `let`.
  • elm / LetRecMultiArgTest
    A recursive two-argument function defined in a `let` block calls itself with both arguments changed; `f 1 1` logs `result: 2`.
  • elm / LocalMultiNonTailRecTest
    A let-bound recursive function that is not tail recursive, with an unannotated polymorphic type, is used at both Int and Float in the same body.
  • elm / LocalRecCaptureBoolTest
    A let-bound recursive function reads a Bool defined earlier in the same `let`, and the loop takes the step size that Bool selects.
  • elm / LocalRecCaptureKindsTest
    A let-bound recursive function that uses an Int, a Float, a Char, a Bool and a String from its enclosing scope gives the same result whether it is called directly or passed to a local `map`.
  • elm / LocalRecCaptureSplitParamTest
    A let-bound recursive function reads a tuple parameter of the tail-recursive function that encloses it.
  • elm / LocalTailRecSimpleTest
    An annotated let-bound tail-recursive function with an accumulator computes the sum 1 + 2 + ... + 10 = 55.
  • elm / MinimalLetRecursionTest
    A let definition of a function that calls itself.
  • elm / MultiLocalTailRecTest
    Two independent self-recursive functions defined in the same `let` block, each calling itself in tail position, both run correctly.
  • elm / MutualLetRecClosuresTest
    Two `let`-bound functions that call each other (`evenP` and `oddP`) are mutually recursive, and each returns a record holding a Bool result and a step count.
  • elm / MutualLetRecManyCapturesTest
    Two mutually recursive `let`-bound functions inside a top-level function, both using all four of the enclosing function's parameters, compute the right result.
  • elm / MutualLetRecNestedTest
    Two mutually recursive `let`-bound functions defined inside a lambda that is returned from a top-level function use that function's parameters after it has returned.
  • elm / PolyLetTailRecTwoTypesTest
    A let-bound, polymorphic, tail-recursive local `foldl` used at two different types in the same expression gives the right result for each.
  • elm / TailLoopMutualRecMutualRecursionInsideATailLoopTest
    A self tail-recursive function whose loop body defines a pair of mutually recursive local functions, and calls one of them to compute the next accumulator, gives the right result.
  • elm / TailRecClosureAccTest
    A tail-recursive accumulator loop defined as a local function in a `let` gives the right result: `go` adds `m` to `acc` while counting `m` down to 0, so `recursiveLet 5` is 5 + 4 + 3 + 2 + 1 = 15.
  • elm / TailRecDeciderSearchTest
    A local function defined in a `let` that calls itself both in a tail position and in a non-tail position, as the scrutinee of a `case`, gives the right result.
  • elm / TailRecFoldlCaseTest
    A hand-written left fold, defined as a self tail-recursive local function in `main`'s `let` and matching on the list with `case`, sums `[ 1, 2, 3 ]` to 6.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:d-dec-rec] 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.